The for loop in Linux
Updated September 12, 2002
Created November 19, 2001


Autogenerated Site Map
Search this Site!:
Search this site powered by FreeFind

Quicklist:

for X in 1 2 3; do echo $X; done
for X in /tmp/*; do echo ls -l /tmp/$X; done
for X in 1 2 3; do echo num${X}oftotal; done

     for X in 1 2 3; do
          echo $X
     done

Command Line mode:

#Listing all the parameters
for X in 1 2 3; do echo $X; done
Output:
1
2
3
#Using filenames as parameters
for X in /tmp/*; do echo ls -l /tmp/$X; done
#When characters immediately follow the variable name, #you may should use curly braces to separate the variable from the text:
for X in 1 2 3; do echo num${X}oftotal; done
Output:
   num1oftotal
   num2oftotal
   num3oftotal

Script Mode:

for X in 1 2 3; do
     echo $X
done

Search this Site!:
Search this site powered by FreeFind

Homepage: http://www.cpqlinux.com
Site Map: http://www.cpqlinux.com/sitemap.html