Hi
Am trying to compare the values of two files..
One is a big file that has many values and the other is a small file..
The big file has all values present in small file..
# cat SmallFile
4456602 22347881
7471282 15859891
8257690 21954701
7078068 18219229
2883826 6094959
100000
#cat BigFile
2556026 4456607
1638400 26935353
1638400 27000891
1638400 27066427
1638400 27131965
2556026 4522129
2556026 4587665
2556026 4653243
2556026 4718739
2556026 4784279
2162828 4849867
2556026 4915351
2556026 4980889
9502866 51904709
2556026 5046427
6553624 52232395
2556026 5111965
2556026 5177503
2556026 5243041
7536864 52560077
8519918 52625643
9568272 52887787
3080288 52953273
13828302 53084411
11337738 53149809
4456602 22347881
7471282 15859891
8257690 21954701
7078068 18219229
2883826 6094959
My problem is when i tried to compare the value present is SmallFile that is not present in BigFile.. My code should return error
But it is returning the return value of grep command as zero
#!/usr/bin/ksh
#set -x
count=`cat SmallFile | wc -l`
while [[ $count -gt 0 ]] && read LINE ; do
d=$LINE
i=`echo $d | cut -f1 -d " "`
td=`echo $d | cut -f2 -d " "`
fmp=`cat BigFile | grep "$i" | awk -F " " '{print $2}'`
RetVal=`echo $?`
echo "The RC val is $RetVal and i value is $i"
if [[ $RetVal -eq 0 ]]; then
if [[ $td -eq $fmp ]]; then
echo "The values from Small File is $td and from BigFile is $fmp"
fi
else
echo "Cannot find match for $i"
fi
count=$(($count-1))
done < SmallFile
Here the "RetVal" when $i=100000 is one.. But it is returning zero..
Please help..