->Title Page
->Intro
->Unix
-->Overview
-->File Structure
-->Online Manual
-->Basic Commands
-->Additional Commands
-->Login files
-->Special characters
-->Miscellaneous Tips
--->Strange names
--->Advanced wildcards
--->Terminal input
--->Remote shell
->Loops in scripts
--->More tricks
-->Things to try
->Vi editor
->Mirror sites
->Further reading

[ Up ]
[Prev][Home][Next]
[Author]

Unix ---> Loops in scripts

Here is an example of a simple loop in a script. I use it to send out my biweekly junkmail messages.1


    #!/bin/sh
    for i in `cat $HOME/jm/list`
    do
      mail -s 'Junkmail message number '$1 $i < jm.$1
    done
The script takes one line at a time from the file $HOME/jm/list and executes the command


    mail -s 'Junkmail message number '$1 $i < jm.$1
where $1 the first argument on the command line calling the script and $i is the line from the file $HOME/jm/list.

Please notify owners of webpages with outdated links to these pages

1 I no longer find the time to continue this. However, I do have a collection of amusing things my professors said while I was in grad school available on my website. (These quotes were a component of my junkmail messages.)

Find this site useful? Want to give something back?

© 1993-2001 Christopher C. Taylor