将来自stdin的行追加到文件中,但仅当这些行尚未出现在文件中时。
新行也会输出到stdout,因此它有点像tee -a,但会去除重复项。
这里,一个名为things.txt的文件包含一个数字列表。newthings.txt包含第二个
数字列表,其中一些出现在things.txt中,另一些则没有。anew被用来
将后者追加到things.txt中。
▶ cat things.txt
Zero
One
Two
▶ cat newthings.txt
One
Two
Three
Four
▶ cat newthings.txt | anew things.txt
Three
Four
▶ cat things.txt
Zero
One
Two
Three
Four
请注意,添加到things.txt的新行也会发送到stdout,这允许它们被
重定向到另一个文件:
▶ cat newthings.txt | anew things.txt > added-lines.txt
▶ cat added-lines.txt
Three
Four
-d。-q。你可以使用go进行安装:
go install -v github.com/tomnomnom/anew@latest
或者为你的平台下载一个二进制发布版。