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". get the zine!
read the transcript!

globs are a way to match strings

beware: the * and the ? in a glob are different than * and ? in a regular expression!!!

bear*

matches -> bear ✓ matches -> bearable ✓ doesn’t match -> bugbear x

bash expands globs to match filenames

smiling stick figure with short curly hair: cat *.txt

bash, represented by a box with a smiley face, thinking: let’s find all the .txt files in this directory…

bash: exec(["cat", "sun.txt" "planet.txt"])

cat, also represented by a box with a smiley face, thinking: sun.txt and planet.txt, got it

(cat doesn’t know that you wrote cat *.txt)

there are just 3 special characters

* matches 0+ characters
? matches 1 character
[abc] matches a or b or c

person: I usually just use * in my globs

use quotes to pass a literal ‘*’ to a command

$ egrep 'b.*' file.txt

the regexp ‘b.*’ needs to be quoted so that bash won’t translate it into a list of files with b. at the start

filenames starting with a dot don’t match

unless the glob starts with a dot, like .bash*
person: ls *.txt
bash: there’s .bees.txt, but I’m not going to include that