3

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!

Tjekkles
  • 5,352
  • 8
  • 36
  • 53
  • Tangentially see also http://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-variable – tripleee Jan 14 '16 at 07:48

1 Answers1

3

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"
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278