uniq -c separate the occurrence number by spaces, which is hard for to cut or awk to separate it out later.
1000_A1\tB1\n
___1_A2\tB2\n
I can solve this problem using sed -r 's/^ *([0-9]+)/\1\t/' to change the delimiter to tab. Then cut -f1 could return:
1000\tA1\tB1\n
1\tA2\tB2\n
But it seems a common usage to have uniq -c separate the number by tab. Why is this feature missing? Is there any other easier way to do so?
sort | uniq -c? – John Flatness Oct 11 '11 at 2:17