I want to put a header to file but I get the first comma in the output. Code
#!/bash/bin
ids=(1 10)
filenameTarget=/tmp/result.csv
:> "${filenameTarget}"
echo "masi" > "${filenameTarget}"
header=$(printf ",%s" ${ids[@]}) # http://stackoverflow.com/a/2317171/54964
sed -i "1s/^/${header}\n/" "${filenameTarget}"
Output
,1,10
masi
Expected output
1,10
masi
Debian: 8.5
Bash: 4.30