Home > diff > diff + print only string from the source file without extra information from the diff

diff + print only string from the source file without extra information from the diff

November 18Hits:1
Advertisement

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)

Answers

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)

Try this:

diff old new|grep "^< "|cut -c 3-

Tags:diff

Related Articles

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.794 s.