The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



Thread: help with Loop
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-01-2002
rooh rooh is offline
Registered User
 

Join Date: Jul 2001
Posts: 62
Unhappy help with Loop

Hi All,
I am currently stuck with a loop and if someone can suggest me a way out . I will be very thankful.

suppose I have a filewhich contains data like:
ABDE345678 24567 JQ12345 8 10 J12
CDEP456789 24564 JQ65432 67 10 J12
I have named this file as print.txt

Now My script is as follows:
Code:
while read record
do 
{
echo $record
refno=`awk '{print $2 }' /home/print.txt`
filename=`awk '{print $1 }' /home/print.txt`
period=`awk '{ print $6 }' $/home/print.txt|cut -c 1`

if [ "$period" = "J" ];then
 if [ -f /home/rooh/$filename ];then
 /bin/lp -d PRINTER_NAME  -onobanner -osrb1 -osre10  /home/rooh/$filename 
 /bin/printf "file for $refno does not exist\n"
 fi
else
 if [ -f /home/rooh/$filename ];then
 /bin/lp -d PRINTER_NAME /home/rooh/$filename 
 else
 /bin/printf "file for $refno does not exist\n"
 fi
fi
}
done<"/home/print.txt"
******************************************
The problem with this script is that It basically searches both the files at the same time and thus cannot find it :
something like this
-f /home/rooh/ABDE345678 CDEP456789

Can somebody kindly suggest me how to go abt it.
Because I want it to first pick up one file and print it & then look for the second or so on...

For help will be highly appreciated.

Thanx.
Rooh

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 08:13 AM.
Forum Sponsor