Like other programming languages, Shell support for loop.
The general format of the for loop:
for variable in list
List is a sequence of a set of values (numbers, strings, etc.), each of which values are separated by a space. Each time through the loop, it will be next on the list a value is assigned to variable.
in list is optional, if you do not use it, for recycling location command line parameters.
For example, the order of output current list of numbers:
for loop in 1 2 3 4 5
echo "The value is: $ loop"
The value is: 1
The value is: 2
The value is: 3
The value is: 4
The value is: 5
Sequentially outputs a string of characters:
for str in 'This is a string'
echo $ str
This is a string
.bash Display in your home directory file starting with:
#! / Bin / bash
for FILE in $ HOME / .bash *
echo $ FILE