Hello, I am trying to compare 2 files and get only the new lines as output. Note that new lines can be anywhere in the file and not necessarily at the bottom of the file.
I have made the following progress so far.
/home/aa>cat old.txt
0001 732 A
0002 732 C
0005 732 D
0010 732 B
/home/aa>cat new.txt
0001 732 A
0002 732 AC
0003 801 A
0005 732 D
0006 908 Z
0010 732 B
0011 512 X
0012 732 Z
/home/aa>sdiff old.txt new.txt | egrep '\\|>'
> 0003 801 A
0010 732 B \ 0006 908 Z
> 0010 732 B
> 0011 512 X
> 0012 732 Z
Expected output
0003 801 A
0006 908 Z
0011 512 X
0012 732 Z
How do I do a cut to get the string after '> ' or '\ ' ?
Is there any easier way than using sdiff, grep and cut?
:wall:
Birei,
Thanks for the update. Note that the first line in your output is a 'Change' line. I am looking for only 'New' lines.
Also note the following error I am getting executing the same command as yours.
/home/aa>cat new.txt | grep -v - -f old.txt
grep: can't open -f
old.txt:0001 732 A
old.txt:0002 732 C
old.txt:0005 732 D
old.txt:0010 732 B