Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I perform diff between old to new files I get that DDDC string exsist in the old file by the sign "<" as the follwoing

diff -w old   new
103a104
> BBB
224c225
< DDDC

But please advice if diff can display only the string DDDC from the old file without the sign as "<" or ">" or some numbers as 103a104 or 224c225 etc and all that silly things

For example (requested output from diff hope it realistic -

diff -w old new
DDDC

I need to get the following format (only the strings that exists in the old file and not appears in the new file)

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Give this a try:

diff --old-line-format=$'%l\n' --new-line-format='' --changed-group-format='%<' --unchanged-group-format='' old new

Also, try this for comparison

join -v 1 <(sort old) <(sort new)
share|improve this answer
add comment

Try this:

diff old new|grep "^< "|cut -c 3-
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.