duplicate values

Hi,

How to enumerate duplicate values, without sorting the file.

example

1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3

Where the first column have the repetead values without sorting,

I would like to get the value of the times that the value is repetead , as I show in the 2 column

Thanks in advance.

I presume the input file only has one column? Try:

awk '{print $1, ++C[$1]}' file
1 Like

Thanks for your help, yes the file has only one column,,
I have try the code , but looks like there is a syntax error.. Please advise

---------- Post updated at 03:26 AM ---------- Previous update was at 03:22 AM ----------

Sorry was my mistake,, The code works fine... Thanks again