find difference between two files using Shell Script - BASH

Use below script to find difference between two file in faster way.....

1). copy paste below script in simplediff.sh

2). chmod 755 simplediff.sh

=====
#!/bin/bash
echo -e "Enter the full path for FILE1:"
read f
echo -e "Enter the full path for FILE2:"
read g
if [ ! -f $f ] || [ ! -f $g ]
then
echo "FILE1 or FILE2 MISSING"
else
echo -e "Enter ( 1 ) to konw Different contents in FILE1\nEnter ( 2 ) to know the Different contents in FILE2"
read h
case "$h" in
1) clear
echo -e "File1:"
echo -e "(First line shows the file's Last Modify time)\n"
/usr/bin/diff -u $f $g | grep '^-'
if [ $? == 1 ]
then
clear
echo -e "\033[33;32m"
echo -e "\n\nNo Different contents Found !\n\n"
echo -e "\033[33;0m"
fi
;;
2) clear
echo -e "File2:"
echo -e "(First line shows the file's Last Modify time)\n"
/usr/bin/diff -u $f $g | grep '^+'
if [ $? == 1 ]
then
clear
echo -e "\033[33;32m"
echo -e "\n\nNo Different contents Found !\n\n"
echo -e "\033[33;0m"
fi
;;
*) clear
echo -e "\033[33;31m"
echo -e "\nWrong Option selected !!!\n"
echo -e "\033[33;0m"
;;
esac
fi

=====



If there is no difference in the mentioned files, you will get



If there is no files or wrong path you have mentioned,




When wrong choice made !!


Otherwise you will get result .........


Comments

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer