次のスクリプトがあります。
#!/bin/sh
Q=`</dev/urandom tr -dc A-Za-z0-9 | head -c30`
mysql -uusername -ppasword accounts -e "update forum set key='$Q' where id='1';"
"forum"、"key"、"id" にバックティック (``) を追加する必要があります。そうしないと、エラーが返されます。
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key='xdindSG7hK9KaYgs9RISJNqrzmn4LJ' where id='1'' at line 1
しかし、バックティックを追加すると、bash はそれらを変数として解釈します。
私は何をすべきか?