Shell script to compare that given two files are same or not, Programming Languages

W.A.S.S to compare that given two files are same or not. If found same then delete the second file.

  echo -e "Enter the 1st File name : \c"

read ffname

echo -e "Enter the 2nd File name : \c"

read sfname

res=`cmp $ffname $sfname|wc -l`

//cmp is used for comparing two files and return where those are different

if [ $res -eq 1 ]

then

         echo "Both files are not same"

else

         echo "Both files are same"

         rm $sfname

fi

 

Output

sh  compare.sh

 

Enter the 1st File name : t1.txt

Enter the 2nd File name : t2.txt

Both files are same

 

Posted Date: 9/26/2012 8:17:05 AM | Location : United States







Related Discussions:- Shell script to compare that given two files are same or not, Assignment Help, Ask Question on Shell script to compare that given two files are same or not, Get Answer, Expert's Help, Shell script to compare that given two files are same or not Discussions

Write discussion on Shell script to compare that given two files are same or not
Your posts are moderated
Related Questions
PLEASE HELP ME ORACLE PROGRAMING TRIGGER

Return a new picture with each pixel''s color values made up of 80% of the color values of the corresponding pixel in the first picture and 20% of the color values of the

Write a program that will allow the user to input the corners of a triangle. The program will draw small yellow circles for each input point, then draw the triangle and calculate t

how to save bulk entries at a time using collections?

Write a program that can facilitate searching by indexing text files according to words. In this task, you are given a large text file, sample.txt, which you will need to index the

Question: (a) What do you understand by the term Postback? (b) Describe five benefits of creating virtual directories while developing an ASP.NET application. (c) Exp

Advantages of java stored procedures Transactions Although a saved process contains SQL orders, once collected it will socialize with SQL Hosting server very diversely from

Windows Presentation Foundation Designed by Microsoft Technologies, the Microsoft Technologies windows Display Groundwork (or WPF) is a computer-software graphic subsystem for maki

Explain the Comma Operator- Computer Programming? The comma has two utilization and the most common use is as a parameter separator for data types and function parameter lists. H

You must implement the control mechanism for the robot arm so that it can safely move the blocks from the source pile to their destination, without colliding with any obstacles or