From 146b6714121e75286aff99c9247aaee44fe52d9d Mon Sep 17 00:00:00 2001 From: Miroslav Franc Date: Mon, 3 Sep 2018 15:54:56 +0200 Subject: [PATCH] add few more for examples, the last two are probably bash specific --- cheat/cheatsheets/for | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cheat/cheatsheets/for b/cheat/cheatsheets/for index 2ca31ff..34902b5 100644 --- a/cheat/cheatsheets/for +++ b/cheat/cheatsheets/for @@ -10,8 +10,26 @@ do echo $var 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 for i in `seq 1 10` do echo $i 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