2017-10-25 3 views
0

次のコマンドを使用して、タブ区切りではなくカンマ区切りで出力する方法はありますか。MySqlコマンドラインcsv

echo "select col1, col2, col3 from newtable" | mysql --column-names > data.csv 

以下を出力します。

col1 col2 col3 
1  Test Test 1 
2  Test Test 2 
3  Test Test 3 

どのようにカンマ区切りファイルを出力しますか。

+0

ホープこれが役に立つことができますhttps://stackoverflow.com/questions/356578/how-to-output-mysql-query-results -in-csv-format –

+0

この質問はリンクされた複製ではありません。 –

答えて

2

ただ、カンマで集計を交換するTRを使用します。

echo "select col1, col2, col3 from newtable" | mysql --column-names | tr "\t" ";" > data.csv 
関連する問題