Unix script Excel report generation
I am creating an Excel file through shell script. The data should be in 4 columns, but the output d开发者_如何学Goata came in one column.
Create a comma-separated values file. Perhaps, depending on your delimiters:
some process creates colon-separated data | while IFS=: read v1 v2 v3 v4; do
printf "\"%s\",\"%s\",\"%s\",\"%s\"\n" \
"$(sed 's/"/""/g' <<< "$v1")" \
"$(sed 's/"/""/g' <<< "$v2")" \
"$(sed 's/"/""/g' <<< "$v3")" \
"$(sed 's/"/""/g' <<< "$v4")" \
>> my_data.csv
done
Try adding new line at the end of each statement.
精彩评论