By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

diff command in unix

snowfall
P: 56
I need to find the difference of two files and save it in third file and process it..
But the outpur of diff command is coming with the 'line number - difference' code.

Eg of my output

i22,26d21
< Use the bc program to convert from decimal to hexadecimal.
< To do so, use the obase command to set the base for output:
39c34,35
< See Section 5.6 for more examples of using bc.

But i want only the lines and not the 'i22,26d21 & < Symbol'..

Pls help..

TIA
Mar 13 '08 #1
Share this Question
Share on Google+
4 Replies

docdiesel
Expert 100+
P: 297
Hi,

if you just need the lines, means their content, you could get them with

Expand|Select|Wrap|Line Numbers
  1. diff .... | grep ^\< | sed s/^\<\ //
But this doesn't give you the information, which line is new nor which one's changed or deleted.

Regards,

Bernd
Mar 13 '08 #2

snowfall
P: 56
Hi,

if you just need the lines, means their content, you could get them with

Expand|Select|Wrap|Line Numbers
  1. diff .... | grep ^\< | sed s/^\<\ //
But this doesn't give you the information, which line is new nor which one's changed or deleted.

Regards,

Bernd
Sorry i dont understand.. Is the syntax like this??

Expand|Select|Wrap|Line Numbers
  1. diff file1 file2 > outfile | grep ^\< | sed s/^\<\ //
pls help...
Mar 13 '08 #3

docdiesel
Expert 100+
P: 297
Hi,

for just getting the new/changed/deleted lines use

Expand|Select|Wrap|Line Numbers
  1. diff  file1.txt file2.txt | grep ^\< | sed s/^\<\ //
If you need the differences in diff.txt, use
Expand|Select|Wrap|Line Numbers
  1. diff  file1.txt file2.txt | tee diff.txt | grep ^\< | sed s/^\<\ //
Regards,

Bernd
Mar 13 '08 #4

snowfall
P: 56
Hi,

for just getting the new/changed/deleted lines use

Expand|Select|Wrap|Line Numbers
  1. diff  file1.txt file2.txt | grep ^\< | sed s/^\<\ //
If you need the differences in diff.txt, use
Expand|Select|Wrap|Line Numbers
  1. diff  file1.txt file2.txt | tee diff.txt | grep ^\< | sed s/^\<\ //
Regards,

Bernd
Thanks Bernd............................................. .......
Mar 14 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.