मेरे पास 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!
उत्तर:
जवाब के लिए 3 № 1कार्य करना चाहिए
#!/usr/bin/env bash
tail -n +4 "$0" | sqlite3
exit $?
-- sql commands
select * from some_table