I have a ksh script that returns a long list of values, newline separated, and I want to see only the unique/distinct values. It is possible to do this?
For example, say my output is file suffixes in a directory:
tar gz java gz java tar class class
I want to see a list like:
tar gz java class
You might want to look at the
uniqandsortapplications.(FYI, yes, the sort is necessary in this command line,
uniqonly strips duplicate lines that are immediately after each other)EDIT:
Contrary to what has been posted by Aaron Digulla in relation to
uniq‘s commandline options:Given the following input:
uniqwill output all lines exactly once:uniq -dwill output all lines that appear more than once, and it will print them once:uniq -uwill output all lines that appear exactly once, and it will print them once: