0

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.

Ambrish
  • 3,627
  • 2
  • 27
  • 42
  • Any chance you could put your description over multiple lines to make it easier to read? Also, what have you done to try and solve this problem? – grail Feb 16 '17 at 15:07
  • 1
    At the very minimum, you need to create some sample input files and the desired output: https://stackoverflow.com/help/mcve – glenn jackman Feb 16 '17 at 16:04
  • 1
    Possible duplicate of [Remove Lines from File which appear in another File](http://stackoverflow.com/questions/4366533/remove-lines-from-file-which-appear-in-another-file) – pii_ke Feb 16 '17 at 17:35

1 Answers1

0

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:

Community
  • 1
  • 1
pii_ke
  • 2,811
  • 2
  • 20
  • 30