| 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.
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-2000 Christopher C. Taylor 
         |