LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2006, 03:21 AM   #1
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Rep: Reputation: 15
Using diff and erasing the lines that match


How do I diff two files and erase the lines that are the same without having to go into an editor?

So if i have

List A
1
2
3
4
5
6

List B
2
4
6

If i diff these two files, i'd want to be able to have
List A -B = C

List C
1
3
5
 
Old 09-20-2006, 04:20 AM   #2
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Pipe is your friend. Also check sed and awk as they would be helpfull.

I think something like "diff list_A list_B > list_C" would work.
 
Old 09-20-2006, 04:30 AM   #3
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Original Poster
Rep: Reputation: 15
No, that would just get me output of the diff...i want to actually get rid of any lines that match in List B.
 
Old 09-20-2006, 04:31 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Using one command:

comm -3 list_A list_B

man comm for details.

Hope this helps.
 
Old 09-20-2006, 04:34 AM   #5
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Original Poster
Rep: Reputation: 15
That is exactly what I was looking for. THANKS!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Erasing a RW CD? katzoo Linux - Newbie 1 09-15-2006 01:44 PM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 10:19 AM
printer printing vertical lines at beginning and end of lines makhand Linux - Hardware 0 09-02-2005 03:03 PM
Dual Boot diff Hard Disk diff OS on Suse 9.1 wilhem Linux - Newbie 1 08-13-2004 07:06 PM
Using diff to compare file with common lines, but at different line numbers jimieee Linux - Newbie 3 05-10-2004 08:26 AM


All times are GMT -5. The time now is 10:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration