I'm trying to come up with an solution to this problem, I need to incrementally count and then print the counts of the unique values in column 1 of a tab delimited text file. Here is an example:
Apple_1 1 300 Apple_2 1 500 Apple_2 500 1500 Apple_2 1500 2450 Apple_3 1 1250 Apple_3 1250 2000
And the desired output is:
Apple_1 1 300 1 Apple_2 1 500 1 Apple_2 500 1500 2 Apple_2 1500 2450 3 Apple_3 1 1250 1 Apple_3 1250 2000 2
I know that I can print the line number in awk with just print NR, but I don't know how to reset it for each unique value of column 1.
Thanks for any help you can offer, I appreciate it.