
Here's a preview from my zine, Bite Size Bash!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

read the transcript!
bash has 3 kinds of quotes
‘single quotes’
$ echo '$HOME\n'
$HOME \n
“double quotes”
$ echo "$HOME \n"
/home/bork\n
(only double quotes expand variables)
$’
$ echo $'$HOME\n'
$HOME
(invisible newline)
(only $'
expands escape sequences like \n
or \'
)
you can quote multiline strings
$ MESSAGE="Usage:
here's an explanation of how to use this script!"
here documents
heredocs are a way to write string containing quotes:
expands variables:
$ cat <<PANDA
he said:
"that's $5"
PANDA
doesn’t expand:
$ cat <<'PANDA'
he said:
"that's $5"
PANDA
a trick to escape any string: !:q
make bash do it for you!
$ # He said "that's $5"
$ !:q
'/# He said "that'\'s $5"'
(3 strings squished together)
escaping and
here are a few ways to get a ‘ or “:
\' and \"
" ' " and ' " '
$'\''
"\""
person: '\''
doesn’t work!
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!