I have a bunch of data as below.1,A9600,001_DIF,NA,TIME,startTime    2,A9600,002_DEP,NA,TIME,startTime3,A9600,003_LIT,NA,TIME,startTime4,A9600,004_ETC,NA,TIME,startTime5,B9600,005_CMP,NA,TIME,startTime6,B9600,006_IMP,NA,TIME,startTime7,B9600,007_DIF,NA,TIME,startTimeand I want them to be modified as below.1,A9600,001_DIF,NA,TIME,startTime1,A9600_1,001_DIF,NA,TIME,startTime1,A9600_2,001_DIF,NA,TIME,startTime1,A9600_3,001_DIF,NA,TIME,startTime  2,A9600,002_DEP,NA,TIME,startTime2,A9600_1,002_DEP,NA,TIME,startTime2,A9600_2,002_DEP,NA,TIME,startTime2,A9600_3,002_DEP,NA,TIME,startTime....How to achieve this using shell commands?
How to duplicate each row using shell comands?
shell script
A simple awk loopawk -v num=3 'BEGIN {OFS=FS=,}   {tmp=$2; print; for (i=1;i<=num;i++) {$2=tmp_i; print}}  ' fileAdjust num as desired.