I have a file with a list of strings. I'd like to extract out the unique strings, in the order that they first appear in the file.
So, for instance, if my file contains:
foo
bar
foo
bar
baz
bar
foo
I'd like to output:
foo
bar
baz
If I just wanted the unique values, I could use sort input|uniq, but this sorts my result alphabetically.
Quite simple in awk:
awk '!a[$0]++'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With