LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Differencre between two text files to a third text file (https://www.linuxquestions.org/questions/linux-newbie-8/differencre-between-two-text-files-to-a-third-text-file-819863/)

techdeep 07-14-2010 07:01 PM

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

sharath patil 07-14-2010 07:08 PM

Try using this:

diff a.txt b.txt >> c.txt

techdeep 07-14-2010 07:13 PM

That gives a lot of other information. I want only the rows from a.txt.
c.txt should have only this.

berbae 07-15-2010 07:43 AM

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.


All times are GMT -5. The time now is 01:21 AM.