Anew: Yet Another Useful Tool for your scripts

Anew is a handy tool created by Tomnomnom for appending lines to a file while ensuring that duplicates are not added, making it useful for scripting and data processing tasks.

Install

go install -v github.com/tomnomnom/anew@latest

Help

$ anew --help  
Usage of anew:  
 -d    don't append anything to the file, just print the new lines to stdout  
 -q    quiet mode (no output at all)  
 -t    trim leading and trailing whitespace before comparison

Usage

(Examples from its Github)

▶ 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

▶ cat newthings.txt | anew things.txt > added-lines.txt
▶ cat added-lines.txt
Three
Four