mirror of
https://github.com/dylanaraps/pure-sh-bible
synced 2024-06-08 08:42:29 +02:00
Merge 6f63d0492f
into 26bc7e8d6c
This commit is contained in:
commit
6677e3e8a8
|
@ -46,6 +46,7 @@ See something incorrectly described, buggy or outright wrong? Open an issue or s
|
|||
* [Loop over a (*small*) range of numbers](#loop-over-a-small-range-of-numbers)
|
||||
* [Loop over a variable range of numbers](#loop-over-a-variable-range-of-numbers)
|
||||
* [Loop over the contents of a file](#loop-over-the-contents-of-a-file)
|
||||
* [Loop over the output of a command](#loop-over-the-output-of-a-command)
|
||||
* [Loop over files and directories](#loop-over-files-and-directories)
|
||||
* [VARIABLES](#variables)
|
||||
* [Name a variable based on another variable](#name-a-variable-based-on-another-variable)
|
||||
|
@ -649,6 +650,14 @@ while IFS= read -r line || [ -n "$line" ]; do
|
|||
done < "file"
|
||||
```
|
||||
|
||||
## Loop over the output of a command
|
||||
|
||||
```shell
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
printf '%s\n' "$line"
|
||||
done <<EOF
|
||||
$(command)
|
||||
EOF
|
||||
## Loop over files and directories
|
||||
|
||||
Don’t use `ls`.
|
||||
|
|
Loading…
Reference in a new issue