我有一个SQLite3命令的文件。例如
.print "This is running in SQLite3!"
我想要的行为
sqlite3 < commands.sql
当我在OSX上运行以下内容时:
./commands.sql
这是我当前的解决方案:
#!/usr/bin/env sqlite3 -init
.print "This is running in SQLite3!"
这有效,但它也会打印一些不需要的行:
-- Loading resources from ./process_errors.sql
Error: near line 1: unrecognized token: "#"
This is running in SQLite3!
应该工作
#!/usr/bin/env bash
tail -n +4 "$0" | sqlite3
exit $?
-- sql commands
select * from some_table