bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to return the line available in FILE1 but not FILE2 i


From: Bob Proulx
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?
Date: Tue, 13 Nov 2012 11:49:34 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

Charles Swiger wrote:
> Peng Yu wrote:
> > I just want to return the line available in FILE1 but not FILE2 in
> > diff. After I read the document, it seems that this is not possible.
> > Could anybody confirm whether this is true? If so, is there an
> > alternative tool that does this? Thanks!
> 
> Using diff will show removed lines with a "-"; otherwise, consider
> using the comm utility since that might be closer to what you want...

You might consider that -u may take an optional number of context
lines to display.

  `-U LINES'
  `--unified[=LINES]'
     Use the unified output format, showing LINES (an integer) lines of
     context, or three if LINES is not given.  *Note Unified Format::.
     For proper operation, `patch' typically needs at least two lines of
     context.

Allowing use like this:

  $ printf "AA\nBB\nCC\n" > 1
  $ printf "AA\nCC\n" > 2
  $ diff -u 1 2
  --- 1      2012-11-13 11:37:56.000000000 -0700
  +++ 2      2012-11-13 11:38:03.000000000 -0700
  @@ -1,3 +1,2 @@
   AA
  -BB
   CC
  $ diff -u0 1 2 | sed "1,2d;/^@@/d"
  -BB
  $ diff -u0 1 2 | sed "1,2d;/^@@/d;s/^-//"
  BB

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]