I want to put a header to file but I get the first comma in the output. Code #!/bash/binids=(1 10)filenameTarget=/tmp/result.csv:> ${filenameTarget}echo masi > ${filenameTarget}header=$(printf ,%s ${ids[@]}) # http://stackoverflow.com/a/2317171/54964sed -i 1s/^/${header}\n/ ${filenameTarget}Output,1,10masiExpected output1,10masiDebian: 8.5Bash: 4.30    
Why this first comma in this printf array?
bash;printf
You left out thebar=${bar:1}line from the answer you linked to; you needheader=${header:1}before your sed line to remove the leading comma.