|
Looping with for statement
Script scr4.sh
Script backup-lots.sh
Now create a file important_data with some numbers in it and then run ./backup-lots.sh important_data, which will copy the file 10 times with 10 different extensions.
As you can see, the variable $1 has a special meaning--it is the first argument on the command-line.
Note, watch for correct syntax:
another correct alternative:
Now modify the script:
Looping over glob expressions
Note, the script above loops over all *.txt files in the current directory so
you need to create several files with .txt extension in this
exercise.
Breaking out of the loops and continuing
which causes program execution to continue on the line after the done.
The continue statement is useful for terminating the current iteration of the loop.
|
|