3 ms·
You can do this without sorting: awk '!x[$0]++'
by sheetjs 12y ago
You can do this without sorting:
awk '!x[$0]++'
- jingo 12y agoI use something like this everyday: awk '!($0 in a);a[$0]; print}' I rarely if ever use uniq to remove duplicates. Sorting is expensive.
- _delirium 12y agoThat's usually faster where possible, but it may cause problems on large data sets, since it loads the entire set of unique strings (and their counts) into an in-memory hash table.