For loop:
Used in the shell for looping. Similar to for in other programming languages, but somewhat different. The For loop is the most common syntax structure in bash.
Common format Format One
For variable
Do
Statement
Done
Format Two
For variable in list
Do
Statement
Done
Format three
for (variable = initial value; condition judgment; variable change)
Do
Statement
Done
If do and for want to be on the same line, you need this
For ARG in [list];d o
Commands ...
Done
ARG will get the variable in the list sequentially
***************************************************************************************************
1, for ((i=1;i<=10;i++));d o echo $ (expr $i \* 4);d One
2. Commonly used in shell is for I in $ (seq)
3, for i in ' ls '
4, for I in ${arr[@]} &NBSP;
5, for I in $*; do&NBSP;
6, for File in/proc/sys/net/ipv4/conf/*/accept_redirects; do&NBSP;
7, for I in F1 F2 F3;d o
8, for I in *.txt&NBSP;
9, for I in $ (ls *.txt) &NBSP; the
for in statement is used in combination with" ' and $ (), with the flaw of "or $ () that would be a row-by-line, which is actually a string array of
10, list=" Rootfs usr data data2 "&NBSP;
for D in $LIST; Do&NBSP;
Use the for in statement to automatically traverse the string by space, &NBSP;
11, for I in {1..10}
12, for I in Stringchar {1..10}
13, awk ' Begin{for (i=1 ; i<=10; i++) Print i} '
Note: The For loop notation in awk is the same as the C language
***************************************************************************************************
For process Control in the shell