osx - sqlite3: dump schema into .sql file from command line -


i'm trying dump schema test.db (i.e. no data) file called schema.sql command line in os x without launching sqlite3.

i know can do:

sqlite3 .open test.db .output schema.sql .schema .quit 

but don't want launch sqlite 3. this...

echo '.output schema.sql' | sqlite3 test.db 

creates empty file this...

echo '.schema' | sqlite3 test.db 

only prints schema. how can write file terminal?

thanks!

the shell allows redirection, , sqlite3 can command parameter:

sqlite3 test.db .schema > schema.sql 

Comments