hi
I have a csv file with few rows
> cat job_stat
1,jobname1,somthing,somthing
2,jobname2,somthing,somthing
3,jobname3,somthing,somthing
4,jobname4,somthing,somthing
I want to add few columns after the 2nd column and then append rest of the columns after the 3rd newly added column.
After adding fields the file should look like this
1,jobname1,status,starttime,somthing,somthing
2,jobname2,status,starttime,somthing,somthing
3,jobname3,status,starttime,somthing,somthing
4,jobname4,status,starttime,somthing,somthing
I can do this by iterating line through the lines
(echo $string | cut -d "," -f -2) appended with ('status,starttime,') appended with (echo $string | cut -d "," -f 3-)
redirecting to a new file and renaming the new file to original file once all the lines are processed.
Is there any easy way to do this in awk or sed.