-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
  • 83,387
  • 30
  • 160
  • 202
0

try this line:

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

didn't test, but should work.

Kent
  • 189,393
  • 32
  • 233
  • 301
0

This might work for you (GNU sed):

sed 's|.*|/&/d|' file1 | sed -f - file2 > file3
potong
  • 55,640
  • 6
  • 51
  • 83