Count the number of times a line is in a file
Posted: Fri May 23, 2008 4:51 am
I want to look at the all of the characters up to the first comma (it may very in size) in a line and see how many times that line shows up in a file and then append that number to the end of the line.
The example file would look like:
1234567890,11111,5/22/2008,6/22/2008,01,400.00
1234567890,11111,5/22/2008,6/22/2008,02,100.00
1234567890,11111,5/22/2008,6/22/2008,03,120.00
0987654321,22222,5/22/2008,6/1/2008,01,123.65
then the out put would be:
1234567890,11111,5/22/2008,6/22/2008,01,400.00,3
1234567890,11111,5/22/2008,6/22/2008,02,100.00,3
1234567890,11111,5/22/2008,6/22/2008,03,120.00,3
0987654321,22222,5/22/2008,6/1/2008,01,123.65,1
Any help is greatly appreciated.
The example file would look like:
1234567890,11111,5/22/2008,6/22/2008,01,400.00
1234567890,11111,5/22/2008,6/22/2008,02,100.00
1234567890,11111,5/22/2008,6/22/2008,03,120.00
0987654321,22222,5/22/2008,6/1/2008,01,123.65
then the out put would be:
1234567890,11111,5/22/2008,6/22/2008,01,400.00,3
1234567890,11111,5/22/2008,6/22/2008,02,100.00,3
1234567890,11111,5/22/2008,6/22/2008,03,120.00,3
0987654321,22222,5/22/2008,6/1/2008,01,123.65,1
Any help is greatly appreciated.