What is the usage of for in linux

WBOY
Release: 2021-12-28 17:46:30
Original
9109 people have browsed it

In Linux, the for command is used to create a loop that loops through a series of values ​​to use a command set in the series. The syntax is "for variable name in value list do command sequence done".

What is the usage of for in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the usage of for in Linux

The for command is provided in the shell, which is used to create a loop that repeats through a series of values. Execute a defined set of commands using a value in the series repeatedly.

The basic format of the for statement is as follows:

for 变量名 in 值列表
do
命令序列
done
Copy after login

Provide a series of values ​​for iteration (the result of the previous output, this sentence is used for input) in the parameter list. There are several different ways to specify values ​​in a list.

Read values ​​in a list:

The most basic way to use the for command is to iterate by defining a column of values ​​in the for command. As shown below↓

What is the usage of for in linux

#After execution, the values ​​assigned to t1 as shown in the figure are output one by one!

What is the usage of for in linux

If you iterate the values ​​in the list, assign other values ​​to the variable and it can continue to be used. The iterated value is the last value.

What is the usage of for in linux

The output results are as follows:

What is the usage of for in linux

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the usage of for in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template