Skip to Content
Navigation:

A stick figure smiling

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!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
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!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)