sqlite3: dump schema into .sql file from command line
FYI you could also have done
( echo .output schema.sql ; echo .schema ) | sqlite3 test.db
This is running two echo commands in a subshell and piping its output.
Or
sqlite3 test.db <<EOF.output schema.sql.schemaEOF
See How does "cat << EOF" work in bash? for what this is doing.