-2

I have two text files:

File 1:
abc 1x21 

and

File 2:
sdc 1x43
xcvyu 03x01
abc 1x21
xyz 4x23

and would like to get

File 3:
sdc 1x43
xcvyu 03x01
xyz 4x23

Found something similar in this thread but it wasn't working for me.

Community
  • 1
  • 1

3 Answers3

1

Simplest solutions if you GNU grep:

$ grep -vxf file1 file2 > file3
sdc 1x43
xcvyu 03x01
xyz 4x23
Chris Seymour
  • 79,902
  • 29
  • 153
  • 193
0

try this line:

awk 'NR==FNR{a[$0];next} !($0 in a)' file1 file2 > file3

didn't test, but should work.

Kent
  • 181,427
  • 30
  • 222
  • 283
0

This might work for you (GNU sed):

sed 's|.*|/&/d|' file1 | sed -f - file2 > file3
potong
  • 51,370
  • 6
  • 49
  • 80