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
Object-oriented programming paradigm Object  Oriented  Programming  is  an  aproach  in  which  a  program  is  viewed  as  a  dynamic  network  of collaborating objects, where

Internal Audit has been asked by the State to review the activities of  The Commission on Workforce Development. The Commission was established several years ago by the state legis

i what to know how setcapture() api work in c#

Design and implement a stringed musical instrument class using the following guidelines: a. Data fields for your instrument should include number of strings, an array of stri

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Oracle 11G Reports We are troubleshooting the pagination of Oracle reports when printed from a browser. We need help determining the issue and correcting within the report ou

The following are required for this lesson: Complete the Project "Adding New Payments," which is the Karate Payments that includes the Adding New Payments, Deleting Payments,

How do i get back data from a FOR loop in order to print them on screen?

Introduction This assignment builds on your application, produced in Assignment 1, which holds a list of cabins, which can be either read in from a text file or just hard coded

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4