The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



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

Join Date: Apr 2008
Location: Bangalore
Posts: 120
Hi,

#!/bin/ksh
cat file1.csv file2.csv >> temp
grep X temp | cut -d"," -f1 | sort -u > final2
while read line
do
line1=`grep $line file2.csv`
if [ $? -eq 0 ]
then
echo $line1 >> final_out
else
line2=`grep $line file1.csv`
echo $line2 >> final_out
fi
done < final2


Output:
001X ,,300
002X ,,300
003X ,,500
004X ,,300
005X ,,600
006X ,,100


Penchal