I created a script that extracts data from a database and loads it to a csv file. I am using
SunOS hstz1454 5.10 system. I am trying to do a sequence at the beginning of each line following with a commma.
Data looks like this below:
1,1,1535,0,1,Y,Y 1,1,1535,10,2,Y,Y 1,1,1535,20,1,Y,Y 1,1,1535,30,2,Y,Y 1,1,1535,40,1,Y,Y
I want my csv file to generate a sequence number at the beginning og each line follow by a comma:
1,1,1,1535,0,1,Y,Y 2,1,1,1535,10,2,Y,Y 3,1,1,1535,20,1,Y,Y 4,1,1,1535,30,2,Y,Y 5,1,1,1535,40,1,Y,Y
Here is my code only prints
1 and does not increment, how can I increment on each new line?
for fname in conv2016_02_cos_speed2percent_data_migration.csv do echo "adds a seq number on each line for $fname" sed 's/.*/1,&/' $fname > tmp.tmp mv tmp.tmp $fname done