Saturday, October 17, 2009

Shell script - Compare two files

#!/bin/bash
clear
ARGV=3
if [ $# -eq 3 ];
then
echo "The following lines are Missing in the Destination File $2" >$3
echo -e "#######################################################################################"echo -e "#\t Please wait…."
while read LINE
do
grep -F "$LINE" $2>/dev/null
if [ $? -eq 0 ];
then
echo "">/dev/null
else
echo "$LINE" >>$3
fi
done <$1
else
echo "Syntax Usage: ./filecompare.sh source destination output"
fi
echo -e "#\t Script Done"
echo -e "#\t `cat $3wc -l` lines are missing in the file $2. Output file is $3"
echo -e "#######################################################################################"

No comments:

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory