5 ms·
I've always viewed `awk '!a[$0]++'` as superior to `sort | uniq` because it preserves order and does not have to sort the data first before deduplicating. But `
by SPBS 7y ago
I've always viewed `awk '!a[$0]++'` as superior to `sort | uniq` because it preserves order and does not have to sort the data first before deduplicating. But `sort | uniq` is much easier to remember.
- asicsp 7y agoOr just `sort -u` (if you are using GNU sort, not sure about other implementations) Another difference is that sort is optimized to handle large files [0] [0] https://unix.stackexchange.com/questions/279096/scalability-of-sort-u-for-gigantic-files https://unix.stackexchange.com/questions/279096/scalability-...
- dyu 7y agoIt appears sort has a --stable flag for order preservation. I actually thought sort was stable by default already, but now I know.