Find the answer to your Linux question:
Results 1 to 4 of 4
hi, I try to compare two text files are same or not. temp1.txt and temp2.txt are located in /usr/local/. I want to compare the two are same or not using ...
  1. #1
    Just Joined!
    Join Date
    Oct 2006
    Posts
    14

    Exclamation how to test two text file equal in size using Script

    hi,

    I try to compare two text files are same or not.

    temp1.txt and temp2.txt are located in /usr/local/.
    I want to compare the two are same or not using linux shell script.


    For that,
    I use
    Code:
    if [ temp1.txt = temp2.txt ]
    then
    
       echo files same
    else
    
     echo files not same
    It gives error.

    can any one give me idea.

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    If I were you, I'd generate an md5sum for each file and compare those.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3
    Linux Newbie
    Join Date
    Aug 2006
    Posts
    226
    You need to use the diff command. It will already be installed on your system. I'd type "man diff" from the terminal to see the usage that works best for you.

  4. #4
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    You could also use cmp; that's more common for binary files.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...