Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Is it possible to return the line available in FILE1 but not FILE2 in diff?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peng Yu  
View profile  
 More options Nov 12 2012, 6:19 pm
Newsgroups: gnu.utils.bug
From: Peng Yu <pengyu...@gmail.com>
Date: Mon, 12 Nov 2012 17:19:35 -0600
Local: Mon, Nov 12 2012 6:19 pm
Subject: Is it possible to return the line available in FILE1 but not FILE2 in diff?
Hi,

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!

--
Regards,
Peng


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Nov 12 2012, 8:03 pm
Newsgroups: gnu.utils.bug
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Mon, 12 Nov 2012 19:47:48 -0500
Local: Mon, Nov 12 2012 7:47 pm
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?
On 2012-11-12, Peng Yu wrote:

> Hi,

> 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!

   Perhaps you want comm instead of diff:

comm -23 FILE

--
   Chris F.A. Johnson                          <http://cfajohnson.com>
   Author:                                     =======================
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Nov 12 2012, 8:18 pm
Newsgroups: gnu.utils.bug
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Mon, 12 Nov 2012 20:14:38 -0500
Local: Mon, Nov 12 2012 8:14 pm
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?
On 2012-11-13, Chris F.A. Johnson wrote:

> On 2012-11-12, Peng Yu wrote:
>> Hi,

>> 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!

>    Perhaps you want comm instead of diff:

> comm -23 FILE

   I meant:

comm -23 FILE1 FILE2

--
   Chris F.A. Johnson                          <http://cfajohnson.com>
   Author:                                     =======================
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Swiger  
View profile  
 More options Nov 12 2012, 7:40 pm
Newsgroups: gnu.utils.bug
From: Charles Swiger <ch...@pkix.net>
Date: Mon, 12 Nov 2012 16:40:01 -0800
Local: Mon, Nov 12 2012 7:40 pm
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?
Hi--

On Nov 12, 2012, at 3:19 PM, 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...

% cat > FILE1
This
is  
a
test
file.
% tail -4 FILE1 >! FILE2                                                                                                                               % diff -bdu FILE1 FILE2
--- FILE1       2012-11-12 16:37:45.000000000 -0800
+++ FILE2       2012-11-12 16:38:11.000000000 -0800
@@ -1,4 +1,3 @@
-This
 is
 a
 test

% comm FILE1 FILE2
This
                is
                a
                test
                file.

Regards,
--
-Chuck


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Cowan  
View profile  
 More options Nov 12 2012, 8:53 pm
Newsgroups: gnu.utils.bug
From: John Cowan <co...@mercury.ccil.org>
Date: Mon, 12 Nov 2012 20:53:01 -0500
Local: Mon, Nov 12 2012 8:53 pm
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?
Charles Swiger scripsit:

> Using diff will show removed lines with a "-";

That's diff -u format.

> using the comm utility since that might be closer to what you want...

That only works if the files are both sorted.

--
Using RELAX NG compact syntax to        John Cowan <co...@ccil.org>
develop schemas is one of the simple    http://www.ccil.org/~cowan
pleasures in life....
        --Jeni Tennison                 <co...@ccil.org>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Proulx  
View profile  
 More options Nov 13 2012, 1:49 pm
Newsgroups: gnu.utils.bug
From: Bob Proulx <b...@proulx.com>
Date: Tue, 13 Nov 2012 11:49:34 -0700
Local: Tues, Nov 13 2012 1:49 pm
Subject: Re: Is it possible to return the line available in FILE1 but not FILE2 in diff?

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »