Results 1 to 5 of 5

Thread: diff number of lines that are different?

  1. #1
    Join Date
    Feb 2007
    Beans
    863

    diff number of lines that are different?

    Hi,

    I would be glad to know the difference in terms of lines that are not same?

    diff file1.txt file2.txt that would ouput 2 if two lines are different.

    Any hint for the almighty command that would perform this would be appreciated if possible

    thank you

  2. #2
    Join Date
    Jan 2010
    Location
    Kolkata India
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: diff number of lines that are different?

    Quote Originally Posted by honeybear View Post
    Hi,

    I would be glad to know the difference in terms of lines that are not same?

    diff file1.txt file2.txt that would ouput 2 if two lines are different.

    Any hint for the almighty command that would perform this would be appreciated if possible

    thank you
    diff output is actually a description of how to transform the file1.txt file into file2.txt.

    Here is a explanation .
    http://lowfatlinux.com/linux-compare-files-diff.html
    “Progress is made by lazy men looking for easier ways to do things”
    — Robert A. Heinlein

  3. #3
    Join Date
    Feb 2007
    Beans
    863

    Re: diff number of lines that are different?

    Code:
    Quote Originally Posted by codemaniac View Post
    diff output is actually a description of how to transform the file1.txt file into file2.txt. Here is a explanation . http://lowfatlinux.com/linux-compare-files-diff.html
    diff -e t.lis s.lis 15d 2a hi there .
    The syntax is line number[, line number end]command [text]
    where command is one one of a, c, d
    . marks the end of the ed command stream

    Count the number of d commands - deletes
    Count the number of a commands - inserts
    Count the number of c commands - changes
    When there is a line range eg., 13,17a subtract 17 - 13 to get the number of lines


    I still have to make it work.... man diff does not give any hint about ouputing hte number of lines

  4. #4
    Join Date
    Feb 2007
    Beans
    863

    Re: diff number of lines that are different?

    Do you think that it would work?

    Code:
    diff in.html in2.html  | egrep -c '^[<]'

  5. #5
    Join Date
    Jan 2010
    Location
    Kolkata India
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: diff number of lines that are different?

    Quote Originally Posted by honeybear View Post
    Do you think that it would work?

    Code:
    diff in.html in2.html  | egrep -c '^[<]'
    diff writes to standard output , hence there is no reasons you cannot do that .
    “Progress is made by lazy men looking for easier ways to do things”
    — Robert A. Heinlein

Bookmarks

Posting Permissions

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