When the shell encounters a string between backquotes


it executes cmd and replaces the backquoted string with the standard output of cmd, with any trailing newlines deleted. Quoting inside backquoted commands is somewhat complicated, mainy because the same token is used to start and to end a backquoted command. As a consequence, to nest backquoted commands, the backquotes of the inner one have to be escaped using backslashes, e.g.

LABNAME=$(echo $labname | tr "[a-z]" "[A-Z]" | sed 's/-/_/g'
cat <<-IOTA >$iota_cfg

Since the LABNAME is a variable defined out of the here document, it must be quoted by braces {}, or error will occur.



  1.  A Guide to Unix Shell Quoting