I have a .csv that follows the pattern "col1","col2","col3" and the first row has headers. I'm trying to use sed to add some additional columns like "col4" where col4 come from a variable.
For example, If I tried to add a column with the header "Athlete" and the rest of the rows are populated by the $NAME variable.
sed -i '1s/$/',\"Athlete\"'/; 2,$s/$/',\"$NAME\"'/' workouts.csv
Right now I end up with
"col","col2","col3","Athlete"
"data","data","data","$NAME"
I'd hope for something like
"col","col2","col3","Athlete"
"data","data","data","Michael"
I've tried surrounding everything in double quotes and tried doubling the double quotes around $NAME.
I've also tried changing the s/regex/replacement/ delimiter to # to make it look cleaner.
I've read through man sed a few times now.
I've also pulled out a few hairs.