Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type backtick in shell string variable

Can anyone tell me how I can type a backtick in my shell variable?

I am building a SQL query in a variable. The column name for that query is also a variable and i need to put it between backticks (it has to be a backtick, not a ' or a ").

example:

SQLQUERY="select `${columnname}` from table"

Thanks!

like image 715
Tjekkles Avatar asked Dec 07 '25 23:12

Tjekkles


1 Answers

Use single quotes around the parts containing the back-ticks, or escape the back-ticks with a backslash:

SQLQUERY='select `'"${columnname}"'` from table'
SQLQUERY="select \`${columnname}\` from table"
like image 163
Jonathan Leffler Avatar answered Dec 10 '25 16:12

Jonathan Leffler