I wrote a Bash script to insert values to an SQLite database. The command is as follows:
sqlite3 ${db_name} "insert into ${table_name} (${column1},${column2}) values ('$f1','$f2');"
This command works fine until the f1
variable contains a single quote:
# E.g., f1="I'm just kidding"
# The command reported an error:
Error: near "m": syntax error
How can we escape the single quote inside the variable?