unique
is a simple tool that outputs the unique lines of its input.
The input can come from stdin
or from a file. See usage.
Use Homebrew
brew install ro-tex/tap/unique
or
brew tap ro-tex/tap
brew install unique
You will need Go for this.
go install github.com/ro-tex/unique@latest
If you prefer a binary, you can download a Linux or Mac one from https://github.com/ro-tex/unique/releases.
When no arguments are given, unique
reads from the standard input.
Running
echo " one\n one\n two\n one" | unique
will output
one
two
In order to read from a file, use the -f
parameter:
unique -f file.dat
That is equivalent to
cat file.dat | unique