Home>Article>Operation and Maintenance> What is the usage of for in linux
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".
#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
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↓
#After execution, the values assigned to t1 as shown in the figure are output one by one!
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.
The output results are as follows:
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!