The UNIX and Linux Forums  

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 -->
  #3 (permalink)  
Old 07-02-2009
lathavim lathavim is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 73
See if this helps.

Code:
while read value1
do
a=`echo $value1 | cut -d ' ' -f1`
b=`echo $value1 | cut -d ' ' -f2`
c=`echo $value1 | cut -d ' ' -f3`
while read value2
do
a1=`echo $value2 | cut -d ' ' -f1`
b1=`echo $value2 | cut -d ' ' -f2`
c1=`echo $value2 | cut -d ' ' -f3`
if [ "$a" = "$a1" ]
then
b2=`expr $b - $b1`
echo $a $b2 $c $c1 >>outfile
fi
done<file2
done <file1
sort -o outfile2 -2 outfile
while read out1
do
x=`echo $out1 | cut -d ' ' -f1`
grep $x outfile2 | head -1 >>finalout
grep -v $x outfile2 >tmp
mv tmp outfile2
done<outfile2


Last edited by Yogesh Sawant; 07-05-2009 at 11:28 AM.. Reason: added code tags