Double-quotes preserve all characters other than "
terminator, $
expansions, `
command substitutions, and \
escapes of any of these characters (and newline removal). Note that the literal \
is preserved unless followed by a special character.
General escapes:
$ printf "\"quoted string\"\\n"
"quoted string"
$ printf "\`\`quoted string''\n"
``quoted string''
$ printf "four\\\\nthree\\\ntwo\\none\n"
four\nthree\ntwo
one
$ echo "var=\`echo \$var\`"
var=`echo $var`
$ echo "var=\$(echo \$var)"
var=$(echo $var)
Variable expansion:
$ var=variable echo "$var \$var \\$var \\\$var"
variable $var \variable \$var
Command substitution:
$ var=variable echo "var=`echo $var`"
var=variable
$ var=variable echo "var=$(echo $var)"
var=variable
Removing newlines:
$ echo "multi\
> -line"
multi-line