How can you find unique lines or duplicate lines in a file based on the content of the first field, or the first n characters ? The uniq command on OS X lacks the -w switch that is available under Linux: -w, --check-chars=N : compare no more than N characters in lines, which solves the problem. Can it be done without reimplementing uniq in awk ?The number of fields is not constant. I would like to use only default tools installed on OS X. I use Macports a lot, but in this case, I don't want to use them.
Unique lines based on the first field
shell;osx;uniq
How about using sort -u?  This can at least sort by the first field: sort -k 1,1 -u input_file