I would like to number lines according to their content: the first line gets number 1, the second line gets number 2 if it's identical to the first and number 1 if it's different, and so on. For example:
asdf
asdf
asdf
asdf
dfg
dfg
dfg
qwert
qwert
er
qwert
er
asdf
Should result in:
1 asdf
2 asdf
3 asdf
4 asdf
1 dfg
2 dfg
3 dfg
1 qwert
2 qwert
1 er
3 qwert
2 er
5 asdf