Since we dont have uniq

Here is it, and it doesnt even need a sort

Basically it goes line by line and only prints it if it hasnt been seen

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cat text.txt | awk '!a[$0]++'
cat text.txt | awk '!a[$0]++'
cat text.txt | awk '!a[$0]++'

If you want to sort the output afterwards (sort by frequency of occurrence)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cat text.txt | awk '!a[$0]++' | sort
cat text.txt | awk '!a[$0]++' | sort
cat text.txt | awk '!a[$0]++' | sort

The end.

Leave a Reply

Your email address will not be published. Required fields are marked *