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

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
Try this...


Code:
while read value1
do
        a=`echo $value1 | cut -d ' ' -f1`
        b=`echo $value1 | cut -d ' ' -f2`
        c=`echo $value1 | cut -d ' ' -f3`
        x=`grep "$a" file2|sort -nr -k2,2|head -1|cut -d' ' -f1`
        y=`grep "$a" file2|sort -nr -k2,2|head -1|cut -d' ' -f2`
        z=`grep "$a" file2|sort -nr -k2,2|head -1|cut -d' ' -f3`
        Diff=`expr $b - $y`
        echo "$a $Diff $c $z" >>outfile
done <file1
Note:
file1 - your first file
file2 - your second file
outfile - the result file