Bash Quoting Difference between double quote and single quote


Double quoteSingle quote
Allows variable expansionPrevents variable expansion
Allows history expansion if enabledPrevents history expansion
Allows command substitutionPrevents command substitution
* and @ can have special meaning* and @ are always literals
Can contain both single quote or double quoteSingle quote is not allowed inside single quote
$, `, ", \ can be escaped with \ to prevent their special meaningAll of them are literals

Properties that are common to both:

  • Prevents globbing
  • Prevents word splitting


$ echo "!cat"
echo "cat file"
cat file
$ echo '!cat'
echo "\"'\""
$ a='var'
$ echo '$a'
$ echo "$a"