我正在尝试将以下输出分配给一个变量
sqlite3 /home/user/db_fake_book_index "select id, page from fb2 where bookcode='$bookcode' and page=$page
如果我运行引用它就像
echo "sqlite3 /home/user/db_fake_book_index \"select id, page from fb2 where bookcode='$bookcode' and page=$page\""
我明白了
sqlite3 /home/user/db_fake_book_index "select id, page from fb2 where bookcode='557S' and page=10"
如果我将它复制到控制台它可以正常工作,但是如果我在脚本中将它包含在 $() 中它不起作用,sqlite 认为变量太多,似乎我的双引号被删除了。
$(printf "sqlite3 /home/user/db_fake_book_index \"select id, page from fb2 where bookcode='$bookcode' and page=$page\"")
这给出了同样的失败