2

I have a data.txt file with a lot of lines in it and a lines.txt that contains some lines.

I want to delete all lines from data.txt that match any line from lines.txt and to save that new file as no_dupplicate_lines.txt. I tried this but it does not work:

LC_ALL=C fgrep -v -f dupp jour_24-06.txt

I looking for a solution a kind of File1 MINUS File2 => File1-File2

Jens
  • 69,818
  • 15
  • 125
  • 179
m3asmi
  • 1,252
  • 1
  • 16
  • 36
  • provide some sample input and desired output. also, this has been asked many times, didn't you find any solution? why isn't the current approach working? – fedorqui Jun 23 '15 at 11:53

1 Answers1

2

Something like this with grep:

grep -vxf lines.txt data.txt > no_dupplicate_lines.txt

Sample:

AMD$ cat lines.txt
Line2
Line4
AMD$ cat data.txt
Line1
Line2
Line3
Line4
Line5
AMD$ grep -vxf lines.txt data.txt
Line1
Line3
Line5

Print the lines that are not matching (-v) the exact lines (-x) from the file lines.txt (-f lines.txt). See man grep for option details.

Arjun Mathew Dan
  • 5,240
  • 1
  • 16
  • 27