Thomas Bishop
Thomas Bishop

Reputation: 1

Remove lines from .txt gawk

Okay so how do I remove lines from new.txt if they're in tried.txt,

For example, if new.txt contains 123 and tried.txt contains 123, so remove 123 from in.txt and output results to new2.txt.

Upvotes: 0

Views: 45

Answers (1)

pii_ke
pii_ke

Reputation: 2891

Using grep:

grep -F -x -v -f tried.txt new.txt > new2.txt

Using awk:

awk "NR==FNR{a[$0];next} !($0 in a)" tried.txt new.txt > new2.txt

Any of the above commands should work for you. See:

Upvotes: 0

Related Questions