Bash - For Statement

About

The for statement in bash

As the for statement is a loop statement, you may be interested to check the other loop statements of Bash

Example

Array

for n in {0..5}
do
  echo "BASH_VERSINFO[$n] = ${BASH_VERSINFO[$n]}"
done  
# BASH_VERSINFO[0] = 3                      # Major version no.
# BASH_VERSINFO[1] = 00                     # Minor version no.
# BASH_VERSINFO[2] = 14                     # Patch level.
# BASH_VERSINFO[3] = 1                      # Build version.
# BASH_VERSINFO[4] = release                # Release status.
# BASH_VERSINFO[5] = i386-redhat-linux-gnu  # Architecture
                                            # (same as $MACHTYPE).

File

With a file.

Locate returns a list of file.

for n in `locate myfile`
do
    echo $n
done

Powered by ComboStrap