mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added two new ways to use for loops.
This commit is contained in:
parent
4320966262
commit
e1365274f7
@ -140,6 +140,20 @@ do
|
||||
echo "$VARIABLE"
|
||||
done
|
||||
|
||||
# They can also be used to act on files..
|
||||
# This will run the command 'cat' on file1 and file2
|
||||
for VARIABLE in file1 file2
|
||||
do
|
||||
cat "$VARIABLE"
|
||||
done
|
||||
|
||||
# ..or the output from a command
|
||||
# This will cat the output from ls.
|
||||
for OUTPUT in $(ls)
|
||||
do
|
||||
cat "$OUTPUT"
|
||||
done
|
||||
|
||||
# while loop:
|
||||
while [ true ]
|
||||
do
|
||||
|
Loading…
Reference in New Issue
Block a user