Write a shell script that checks if the contents of two files are same. If so, delete the second file.

Write a shell script that checks if the contents of two files are same. If so, delete the second file.

Code:

clear 
echo --------------------------------------------------- 
echo '\tCheck the file , Delete if it same' 
echo --------------------------------------------------- 
echo Enter the first file name 
read first 
echo Enter the second file name 
read second 
if cmp $first $second 
then 
        rm $second 
        echo The file is deleted. 
else 
        echo Not Equal. 
fi 

Output:

--------------------------------------------------- 
Check the file , Delete if it same 
--------------------------------------------------- 
Enter the first file name 
vvv 
Enter the second file name 
vvv1 
The file is deleted. 

No comments

Powered by Blogger.