Linux and Unix for, foreach and repeat
Quick links
About for, foreach and repeat
Syntax
Examples
Related commands
Linux and Unix main page
Shell built-in functions to repeatedly execute action(s) for a selected number of times.
for word [ in wordlist ... ] ; do actions ; done
foreach word ( wordlist )
[ ... ]
end
repeat count command
for file in *.txt ; do wc -l $file ; done
In ksh (Korn Shell) would do a word count of the files *.txt until done and would return results similar to the below example.
5 myfile.txt
2 myfile2.txt
14 newfile.txt
