sqlite3: dump schema into .sql file from command line
<p>I'm trying to dump the schema for <code>test.db</code> only (i.e. no data) into a file called <code>schema.sql</code> from the command line in OS X without launching sqlite3.</p>

<p>I know I can do:</p>

<pre><code>sqlite3
.open test.db
.output schema.sql
.schema
.quit
</code></pre>

<p>But I don't want to launch sqlite 3. This...</p>

<pre><code>echo '.output schema.sql' | sqlite3 test.db
</code></pre>

<p>creates the empty file but this...</p>

<pre><code>echo '.schema' | sqlite3 test.db
</code></pre>

<p>only prints the schema. How can I write it to that file from Terminal? </p>

<p>Thanks!</p>