Loop
For Statement
The var
variable can be normally used outside the loop body.
Storing a list in a variable.
Command substitution.
Wildcard iteration over a directory.
IFS - Internal Field Separator
The environment variable IFS (Internal Field Separator) specifies the field separator.
The default value is empty, indicating that the following characters are separated.
- Space
- Tab
- Newline
Separating by Newline
Separating by Multiple Symbols
Indicates that newline, colon, semicolon, and double quotes are used as separators.
For Loop in C Language
The i
variable can be normally accessed outside.
While Statement
Multiple while
conditions are judged by the exit code of the last condition.
Until Statement
Break Statement
Supports specifying the number of loop levels to exit.
The break
statement defaults to 1, indicating exit from 1 level of loop.
Continue Statement
Like break
, the default is also 1.
Loop Output Redirection
The standard output of the loop can be redirected.
The output of the loop body will be redirected to output.txt
.
Loop Output Pipe
The output of the loop body can also be piped.
Summary
I surprisingly like the syntax sugar of break
.