linux 中提取两个文件中各自的特有项

 

1、

root@PC1:/home/test4# ls
a.txt  b.txt
root@PC1:/home/test4# cat a.txt
a
a
b
b
c
d
e
root@PC1:/home/test4# cat b.txt
c
d
e
f
f
g
root@PC1:/home/test4# grep -v -f a.txt b.txt           ## 提取b.txt中的特有项
f
f
g
root@PC1:/home/test4# grep -v -f a.txt b.txt | sort -u
f
g
root@PC1:/home/test4# grep -v -f b.txt a.txt           ## 提取a.txt中的特有项
a
a
b
b
root@PC1:/home/test4# grep -v -f b.txt a.txt | sort -u
a
b

 

posted @ 2022-05-27 11:40  小鲨鱼2018  阅读(55)  评论(0)    收藏  举报