-1

I have 2 files, source.txt and old.txt. Wanting to compare and remove of lines, So anything in both old.txt and source.txt, is removed from source.txt

source.txt:

abc.com
def.com
ghi.com
123.com
456.com
789.com
700.com
710.com

old.txt:

123.com
700.com
def.com

output (updated source.txt):

abc.com
ghi.com
456.com
789.com
710.com
Janet D
  • 23
  • 3

2 Answers2

1
perl -ne'
   BEGIN { local $/; ++$remove{ $_ } for split /^/m, <> }
   print if !$remove{ $_ };
' old.txt source.txt
ikegami
  • 367,544
  • 15
  • 269
  • 518
1

Why not just use grep(1):

grep -v -f old.txt source.txt
TLP
  • 66,756
  • 10
  • 92
  • 149
ernix
  • 3,442
  • 1
  • 17
  • 23