The simple bash loop to do something with all files in the directory is:
for f in * ; do echo $f ; done
which just displays all files in this case.
This is easy, what I usually need and often forget how to do it is to execute some action exact number of times. Something like simple for loop in C or Java. And there is an exact match for such loop in Bash too:
for (( i=1 ; i<=100 ; ++i )) ; do echo $i ; done
I found another similar solution on the Internet today at spiralbound.net:
for i in $(seq 1 100); do echo $i ; done
which might useful in some cases...
Recent comments
10 weeks 5 days ago
20 weeks 1 day ago
21 weeks 1 day ago
43 weeks 8 hours ago
43 weeks 3 days ago