How do i Get return value (0/1) after comparing the two Files using 'cmp' Command ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xtremebass
    New Member
    • Nov 2008
    • 38

    How do i Get return value (0/1) after comparing the two Files using 'cmp' Command ??

    Hi Bytes..

    In Linux, How can i get return value of comparing two files using the command cmp in the prompt.. when i was tried, it shows only output of unmatched lines(differ line )/ shows nothing if two file are same. please do help..

    Thanks.
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    This should work for you...
    Code:
    if cmp a1.txt b1.txt > /dev/null
    then
            echo "Files are same..."
    else
            echo "Files are different..."
    fi

    Comment

    Working...