1
我想在bash脚本运行的sqlite一系列命令:如何在bash脚本中运行sqlite3?
db="main.sqlite3"
db2="sub.sqlite3"
sqlite3 ${db} <<EOF
attach ${db2} as m;
select count(*) from m.details;
.exit
EOF
当连接到一个字符串,它的工作原理,但是当它是一个变量,它不会,得了
Error: near line 1: near "/": syntax error
如何在EOF中使用变量(db2)?感谢
这应该是写的。您发布的代码段中没有'/',那么您是否可以简化它太多? – Thomas
我建议检查你的文件是否有特殊字符:'cat -A file'或'cat -v file' – Cyrus
'attach'语句是否需要引用dbname?你需要'附加'$ db2'作为m;'?我无法从https://sqlite.org/syntax/attach-stmt.html和https://sqlite.org/syntax/expr.html –