1. 程式人生 > 其它 >linux 列印兩個檔案內容相同行和不同行(交集和差集)

linux 列印兩個檔案內容相同行和不同行(交集和差集)

技術標籤:linux運維linux

test1檔案

dw
dsa
sd
a
2
2
32
21
32
12
23
ew
dawd
ra
我ca
dawda
行吧666

test2 檔案

1dw
2dsa
ssd
a
2
2
32
21
32
12
23
ew
dawd
ra
我我ca
dawda
行吧666

列印檔案相同行(交集)
grep -Fxf test1 test2
在這裡插入圖片描述

檔案內容差集
grep -vxf test1 test2
在這裡插入圖片描述