Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove string from file if found in another file 2

Status
Not open for further replies.

thedaver

IS-IT--Management
Jul 12, 2001
2,741
US
Oh scripting gurus, my sed's weak and I hate to make perl out of the this....

I have large text file "A" and short text file "B".

"B" represents strings I need to remove (whole line matching) if they appear in "A".

THUS: if "A" is

Code:
apple
banana
grape
mango
peach
pear

and "B" is

Code:
banana
mango

I want to modify "A" to read:

Code:
apple
grape
peach
pear

Again, whole line pattern matching... I'm on very little sleep and this is not clicking for me... I know it's easy..
HELP appreciated.

D.E.R. Management - IT Project Management Consulting
 
Code:
grep -v -x -f fileb filea
ought to do it. Pipe the output wherever you want.
 
Hmm... seems I was way too slow. But in my defence, grep doesn't require them to be sorted...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top