Added loops
This commit is contained in:
parent
8bd977f5d3
commit
b162634394
|
@ -65,6 +65,7 @@ scripts and not full blown utilities.
|
|||
* [Loop over a variable range of numbers.](#loop-over-a-variable-range-of-numbers)
|
||||
* [Loop over an array.](#loop-over-an-array)
|
||||
* [Loop over an array with an index.](#loop-over-an-array-with-an-index)
|
||||
* [Loop over the contents of a file.](#loop-over-the-contents-of-a-file)
|
||||
* [Loop over files and directories.](#loop-over-files-and-directories)
|
||||
* [File handling](#file-handling)
|
||||
* [Read a file to a string.](#read-a-file-to-a-string)
|
||||
|
@ -601,6 +602,14 @@ for i in "${!arr[@]}"; do
|
|||
done
|
||||
```
|
||||
|
||||
## Loop over the contents of a file.
|
||||
|
||||
```shell
|
||||
while read -r line; do
|
||||
printf '%s\n' "$line"
|
||||
done < "file"
|
||||
```
|
||||
|
||||
## Loop over files and directories.
|
||||
|
||||
Don’t use `ls`.
|
||||
|
|
Loading…
Reference in New Issue