LinuxQuestions.org
Help answer threads with 0 replies.
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 07-14-2010, 08:01 PM   #1
techdeep
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
Differencre between two text files to a third text file


Hi!
I want the difference of two text files(a.txt & b.txt) into a third text file(c.txt).
i.e. New or Differert rows of a.txt compared to b.txt

a.txt>
10128|10153|999999
10343|10153|000
10345|10153|3846
10351|10153|3846

b.txt>
10128|10153|999999
10343|10153|3853
10345|10153|3853
10349|10153|3853

c.txt should be like>
10343|10153|000
10351|10153|3846

I tried comm,but man says that the files have to be sorted in order to use comm. I dont want to sort the files.

Thanks in Advance
 
Old 07-14-2010, 08:08 PM   #2
sharath patil
LQ Newbie
 
Registered: Apr 2006
Location: India
Posts: 4

Rep: Reputation: 0
Try using this:

diff a.txt b.txt >> c.txt
 
Old 07-14-2010, 08:13 PM   #3
techdeep
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Original Poster
Rep: Reputation: 0
That gives a lot of other information. I want only the rows from a.txt.
c.txt should have only this.
 
Old 07-15-2010, 08:43 AM   #4
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Code:
diff --suppress-common-lines --side-by-side a.txt b.txt|cut -f 1 >c.txt
I don't understand why the third line of a.txt is not present in your c.txt of your opening post, because it is different from the third line of b.txt.
 
  


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
join 2 text files based on first number present in every line of the 2 text files markraem Linux - Software 4 01-25-2010 07:26 AM
Linux Text File convert to Windows/Notepad Text File = Wrapped? backroger Linux - Software 4 01-18-2009 06:54 AM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 10:40 PM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 03:36 PM
Steps needed to convert multiple text files into one master text file jamtech Programming 5 10-08-2007 12:24 AM


All times are GMT -5. The time now is 09:09 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