开发者

Unix script Excel report generation

开发者 https://www.devze.com 2023-03-21 03:23 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消