Thread: "diff" question

  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power

    "diff" question

    hi everybody,

    i had a question regarding the "diff" command. if i do
    "diff filea fileb > filec"

    is there a way to keep only the data differences ignoring the ">", "----", line numbers, etc that diff prints along with the differences ??

    any help would be greatly appreciated
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Rep Power
    Well, looking at the man pages for diff doesn't seem too encouraging for having diff itself do it, or any of its variants for that matter either (taken from man pages on a Solaris 8 Sparc system)

    You could get the results you want from other programs however:

    First, diff the files to a third file, I'll call it newfile, and then run something like the following:

    cat newfile | sed s/\<\ //g | sed s/\>\ //g > cleanfile

    Basically, that will remove all the '<' and '>' and the following spaces (so as to align the output properly to the left margin).

    Run another sed command and you could get rid of the '---' and number lines as well. Or, awk might work as well.

    Hope this helps.


IMN logo majestic logo threadwatch logo seochat tools logo