The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-28-2009
cambridge cambridge is offline
Registered User
  
 

Join Date: May 2009
Posts: 55
Quote:
Sorry still don't get it, new at this stuff
when I have the shl like this one, it worked, it is only when I try to code to send emails,
Code:
echo $i `date` > idochd1.lst
cp $i idoc.dat
.....
for i in 3526*.dat 
do
...
done
...does not work because $i is not set when you are outside the for loop.

Code:
for i in 3526*.dat              
do
...
echo $i   `date` > idochd1.lst
cp $i idoc.dat
...
done
...works because your references to $i come inside the for loop (between the do and done).

This is basic shell stuff, I suggest you buy a book on UNIX shell scripting and work through some examples.