我有两个文件:A和B.
A的内容:
http://example.com/1
http://example.com/2
http://example.com/3
http://example.com/4
http://example.com/5
http://example.com/6
http://example.com/7
http://example.com/8
http://example.com/9
http://example.com/4
文件B的内容:
http://example.com/1
http://example.com/3
http://example.com/9
http://example.com/4
现在,我想从文件A中删除文件B中所有行的出现。
我试过以下:
for LINK in $(sort -u B);do sed -i -e 's/"$LINK"//g' A; echo "Removed $LINK";done
但它根本没有做任何事情。
答案 0 :(得分:4)
grep -vf
对此更简单:
grep -vxFf file2 file1
http://example.com/2
http://example.com/5
http://example.com/6
http://example.com/7
http://example.com/8