sqlite3 output with tabs from one line command

Viewed 11353

I want to have my sqlite3 output separated by tabs. The -column option does not suit me because separate records with spaces and my values have spaces but no tabs.

If I use interactively sqlite3 I can use .mode tab. The one-line command has the option -separator but I don't know how to add a tab there that gets interpreted as a tab not literal (probably with and ASCII code?)

Any suggestions? All the google examples that I found was for interactive sqlite3.

At the moment I am using the brute force approach:

sqlite3 -header mydb "select * from table1" | tr \| '\t' > myoutput
3 Answers

This works on both Linux and Windows:

sqlite3 -header -cmd ".mode tabs" mydb "select * from table1"
Related