mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 23:33:00 +03: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"
|
echo "$VARIABLE"
|
||||||
done
|
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 loop:
|
||||||
while [ true ]
|
while [ true ]
|
||||||
do
|
do
|
||||||
|
Loading…
Reference in New Issue
Block a user