firstFile=$1
secondFile=$2
cmp $firstFile $secondFile | grep -q differ
if [ $? == 1 ]
then
rm -rf $secondFile;
echo "$firstFile and $secondFile are same !"
echo "Deleted $secondFile"
else
echo "$firstFile and $secondFile are different !"
fi
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts# cat testFile
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# cat testFile2
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# ./rmDiffFile.sh testFile testFile2
#testFile and testFile2 are same !
#Deleted testFile2
#root@slack-linunx:~/scripts#
secondFile=$2
cmp $firstFile $secondFile | grep -q differ
if [ $? == 1 ]
then
rm -rf $secondFile;
echo "$firstFile and $secondFile are same !"
echo "Deleted $secondFile"
else
echo "$firstFile and $secondFile are different !"
fi
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts# cat testFile
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# cat testFile2
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# ./rmDiffFile.sh testFile testFile2
#testFile and testFile2 are same !
#Deleted testFile2
#root@slack-linunx:~/scripts#
0 comments:
Post a Comment