bash 命令删除其他文本文件中存在的行
bash command to remove lines which are present in other text file
我在 bash 我有两个文件 added.txt 和 unmatched.txt ,现在假设 added.txt 中的所有行都出现在 unmatched.txt 中。我想从 unmatched.txt 中删除 added.txt 中存在的行。例如
1) added.txt
apple
ball
2) unmatched.txt
cat
dog
apple
rar
ball
3) 需要 output.txt
cat
dog
rar
与 grep
相关:
$ cat added.txt
cat
dog
$ cat unmatched.txt
aardvark
cat
dog
giraffe
civet cat
$ grep -F -vx -f added.txt unmatched.txt
aardvark
giraffe
civet cat
只打印 unmatched.txt
的行与 added.txt
的行不完全匹配(-v
反转 grep
的通常含义)。
我在 bash 我有两个文件 added.txt 和 unmatched.txt ,现在假设 added.txt 中的所有行都出现在 unmatched.txt 中。我想从 unmatched.txt 中删除 added.txt 中存在的行。例如
1) added.txt
apple
ball
2) unmatched.txt
cat
dog
apple
rar
ball
3) 需要 output.txt
cat
dog
rar
与 grep
相关:
$ cat added.txt
cat
dog
$ cat unmatched.txt
aardvark
cat
dog
giraffe
civet cat
$ grep -F -vx -f added.txt unmatched.txt
aardvark
giraffe
civet cat
只打印 unmatched.txt
的行与 added.txt
的行不完全匹配(-v
反转 grep
的通常含义)。