【发布时间】:2021-12-01 00:54:56
【问题描述】:
我有两个文件
file1.txt
a
b
c
file2.txt
a
b
c
d
现在使用 grep 命令
grep -vf file1.txt file2.txt
会给我输出 ->
d
但是使用它我无法将此结果保存在任何文件file1 或file2 中。我想简单地在任何一个文件中覆盖这个结果。
如何使用 grep 来完成?
【问题讨论】:
-
您正在寻找 linux 中的附加运算符。 '>' 或 '>>'。 Here is an answer showing how to string a grep command into a file append/overwrite.