Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHILE LOOP that won't fail

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
0
0
GB
Loops in Unix seem to be the bane of my life. Can someone put me out of my misery and tell me what I am doing wrong in the code below. As I cannot get it to fail and exit the loop

ls $CTM_FTPIN | grep trigger | grep > filelist
while [ -s $filelist ]; do
do some coding here


nawk -v mnem=$mnem -v runopt=$run_opt -v batch=$batch_id -f aftn3220.awk filelist > filelist2 - this one line off the filelist

mv filelist2 filelist - replace the original file
done


What am I doing wrong here as I cannot get the loop to fil when the file is empty

Thanks
Bob
 
shouldn't this

while [ -s $filelist ]; do

be

while [ ! -s $filelist ]; do

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Change this:
while [ -s $filelist ]; do
by this:
while [ -s filelist ]; do

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
RJSHA1: your script

ls $CTM_FTPIN | grep trigger | grep > filelist
while [ -s $filelist ]; do
do some coding here
...
done


a) the second grep is hanging, what should it do??
b) PHV's remark is correct, $filelist points to nothing.
c) why so complex? for what do you need a file?

for file in 'ls $CTM_FTPIN' # this are back quotes
do
case $file in *trigger*) ;; *) continue;; esac
exec-your-code $file
done




:) guggach
 
Cheers for all the comments guys..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top