我有兩個文本文件:刪除線包含從另一個文件採取了一定的字符串
File 1:
abc 1x21
和
File 2:
sdc 1x43
xcvyu 03x01
abc 1x21
xyz 4x23
,並希望得到
File 3:
sdc 1x43
xcvyu 03x01
xyz 4x23
找到東西在this thread類似,但它不適合我。
我有兩個文本文件:刪除線包含從另一個文件採取了一定的字符串
File 1:
abc 1x21
和
File 2:
sdc 1x43
xcvyu 03x01
abc 1x21
xyz 4x23
,並希望得到
File 3:
sdc 1x43
xcvyu 03x01
xyz 4x23
找到東西在this thread類似,但它不適合我。
嘗試這一行:
awk 'NR==FNR{a[$0];next} !($0 in a)' file1 file2 > file3
沒有測試,但應該工作。
最簡單的解決,如果你GNU grep
:
$ grep -vxf file1 file2 > file3
sdc 1x43
xcvyu 03x01
xyz 4x23
這可能爲你工作(GNU SED):
sed 's|.*|/&/d|' file1 | sed -f - file2 > file3