When I use the commands below in a shell script, it writes 1, 2, and 3 in the first three cells of the first row.
values=1,2,3
echo $values | tee test.csv
I am wondering how we can instead create a csv file with the numbers written vertically in the first column.
CodePudding user response:
echo $value | sed "s/,/\n/g" | tee test.csv
Adding a simple sed command to replace commas with the newline character should do the work. Sed is substituting all occurrences of , with \n i.e. new line character.
