for statement
for statement executes the commands which are contained within do and done, a specified number of times.
Syntax
for variable in list-of-commands
do
commands
done
Practice 1
The given shell program will convert all the file content to uppercase begin with a as first name and through creating with similar file name and extension as caps.
# vi upperconv
for fname in ls a*
do
tr "[a-z]" "[A-Z]" < $fname > $fname.caps
done
# sh upperconv
The given program will search the filename that begins with a as the first letter and open the file ID will then convert the whole file content into uppercase and store it in a file with the similar filename but with extension in caps.