The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m ascii eof autosys awk trim bash eval bash exec bash for loop bash subroutine boot: cannot open kernel/sparcv9/unix close_wait curses.h dead.letter find grep grep multiple lines grep or grep recursive grep unique inappropriate ioctl for device logrotate.conf lynx javascript mailx attachment make: fatal error: command failed for target `all-recursive' mget mtime perl array length ping port read awk output into multiple variables replace space by comma , perl script scp recursive segmentation fault(coredump) sftp batch sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix for loop unix forum unix forums unix interview questions unix memory usage unix mtime unix simulator unix.com while loop within while loop shell script

View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-09-2008
ksmbabu ksmbabu is offline
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 14
How to handle multiple rows in a file

I have a FILE a.txt which has the following data

113901.94,113901.94,56950.97,56950.97,NOT MATCHING,NOT MATCHING
10693.04,10693.04,5346.52,5346.52,NOT MATCHING,NOT MATCHING
1901.94,1901.94,550.97,550.97,NOT MATCHING,NOT MATCHING
103.04,103.04,53.52,53.52,NOT MATCHING,NOT MATCHING

#### This IS my Code ####

RECIPIENT="xyz@mail.com"
FILE_PATH=/path/
cd $FILE_PATH
FILE=a.txt
chmod 777 $FILE

tgt_dr=`cat a.txt | awk -F',' '{print $1}' $FILE`
tgt_cr=`cat a.txt | awk -F',' '{print $2}' $FILE`

src_dr=`cat a.txt | awk -F',' '{print $3}' $FILE`
src_cr=`cat a.txt | awk -F',' '{print $4}' $FILE`

### Comparing for the Credit Amount

if [ -s $FILE ]
then

if [ $src_cr -eq $tgt_cr ]
then
exit 0
else
(echo "Hi All,


The sum of credit amount : $src_cr
The sum of credit amount : $tgt_cr


Thanks
user_name" )|mailx -s "`date '+%d-%m-%y'` Credit Amount" $RECIPIENT
fi
else
exit 0
fi

### Comparing for the Debit Amount

if [ -s $FILE ]
then
if [ $src_dr -eq $tgt_dr ]
then
exit 0
else
(echo "Hi All,

The sum of debit amount : $src_dr
The sum of debit amount : $tgt_dr


Thanks
User_name" )|mailx -s "`date '+%d-%m-%y'` Debit Amount" $RECIPIENT
fi
else
exit 0
fi

as of now my program handle only one row. pl let me know how to achieve this in looping if i have
multiple lines in the a.txt file

Thanks
Babu
Reply With Quote
Forum Sponsor