Is there a way to use the following command to output in comma separated instead of tab separated.
echo "select col1, col2, col3 from newtable" | mysql --column-names > data.csv
It outputs the following.
col1 col2 col3
1 Test Test 1
2 Test Test 2
3 Test Test 3
how do I output a comma seperated file.
Answer
Just use tr to replace tabulations by commas:
echo "select col1, col2, col3 from newtable" | mysql --column-names | tr "\t" ";" > data.csv
No comments:
Post a Comment