mirror of
https://github.com/cheat/cheat.git
synced 2024-11-22 22:11:35 +01:00
Merge pull request #393 from mirekfranc/for-loop-extended
for: add few more for examples, the last two are probably bash specific
This commit is contained in:
commit
f0bd3ba4e6
@ -10,8 +10,26 @@ do
|
|||||||
echo $var
|
echo $var
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# loop over all the JPG files in the current directory
|
||||||
|
for jpg_file in *.jpg
|
||||||
|
do
|
||||||
|
echo $jpg_file
|
||||||
|
done
|
||||||
|
|
||||||
# loop specified number of times
|
# loop specified number of times
|
||||||
for i in `seq 1 10`
|
for i in `seq 1 10`
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# loop specified number of times: the C/C++ style
|
||||||
|
for ((i=1;i<=10;++i))
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done
|
||||||
|
|
||||||
|
# loop specified number of times: the brace expansion
|
||||||
|
for i in {1..10}
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user