0

I am on bash I have two files added.txt and unmatched.txt , now imagine that all lines from added.txt are present in unmatched.txt . I want to remove lines from unmatched.txt which are present in added.txt . for example

1) added.txt

apple
ball

2) unmatched.txt

cat
dog
apple
rar
ball

3) required output.txt

cat
dog
rar
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
karkator
  • 51
  • 1
  • 10
  • 2
    This is NOT clear at all, please do add 3 things in your post.1- Sample of input, 2- sample of expected output and 3rd- your efforts. Kindly EDIT your post and let us know then? – RavinderSingh13 Feb 04 '20 at 09:28
  • Thanks for adding samples in your question, kindly do add your efforts too in your question which you have put in order to solve your own problem. – RavinderSingh13 Feb 04 '20 at 09:52

1 Answers1

0

Trivial to do with grep:

$ cat added.txt
cat
dog
$ cat unmatched.txt
aardvark
cat
dog
giraffe
civet cat
$ grep -F -vx -f added.txt unmatched.txt
aardvark
giraffe
civet cat

Prints just lines of unmatched.txt that don't exactly match lines of added.txt (-v inverts the usual meaning of grep).

Shawn
  • 47,241
  • 3
  • 26
  • 60