Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell script which receives two file names as arguments and checks whether the two file contents are same or not. If same then delete second file

Posted By: Addie Fischer     Category: Unix / Linux / Ubuntu     Views: 11147

Write a shell script which receives two file names as arguments .It should check whether the two file contents are same or not. If they are same then second file should be deleted.

Code for Shell script which receives two file names as arguments and checks whether the two file contents are same or not. If same then delete second file in Unix / Linux / Ubuntu

echo "Enter first file name "
read file1
echo "Enter second file name "
read file2

cmp $file1 $file2 > error

total=`wc -c error | cut -f 7 -d " "`
echo $total

if [ $total -eq 0 ]
then
        echo "Both file's contents are same"else
        echo "Both file's contents are not same"
fi
  
Share: 



Addie Fischer
Addie Fischer author of Shell script which receives two file names as arguments and checks whether the two file contents are same or not. If same then delete second file is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Pawan Kumar from Australia Comment on: Apr 27
what does means error in this program.please explain as soon as possible.
thanking you

View All Comments