如何在 GREP 中只打印两个文本文件的不同行?我只需要打印不在第二个文本文件中的行......
谢谢你。
You can use -F -f <file>
:
grep -Fvf file2 file1
This tells you the lines of file1
which do not (-v
) appear in file2
.
Why do you need to use grep?
Sounds like you need diff
$ cat file1
a
b
c
$ cat file2
b
You can use diff to compare them:
$ diff file1 file2
1d0
< a
3d1
< c
Use -y option to generate better visaul comparison:
$ diff -y file1 file2
a <
b b
c <