How to use for in linux
This article mainly shows you "how to use for in linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use for in linux" this article.
In linux, the for command is used to create a loop that uses a command set in the series through a loop of values, with the syntax "for variable name in values list do command sequence done".
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What is the use of for in linux
The for command is provided in shell to create a loop that repeats through a series of values, executing a defined set of commands using one value in the series at a time.
The basic format of the for statement is as follows:
For variable name in values list do command sequence 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 the values in the list:
The most basic use of the for command is to iterate by defining a list of values in the for command. The following figure is ↓
After execution, the values assigned to T1 as shown in the figure are output one by one!
If you iterate through a value in the list, you can continue to use it by assigning other values to the variable, and the value of the iteration is the last value.
The output is as follows:
The above is all the contents of the article "how to use for in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!