3

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.

2

1 Answer 1

3

Just use tr to replace tabulations by commas:

echo "select col1, col2, col3 from newtable" | mysql --column-names | tr "\t" ";" > data.csv
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.