I am creating an Excel file through shell script. The data should be in 4 columns, but the output data came in one column.
2 Answers
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