
This is a page from an upcoming zine called "The Secret Rules of the Terminal".
To get an email when the zine comes out, sign up for the zine announcements list!

read the transcript!
handle filenames starting with a dash with --
or ./
mv -- -file.txt dest
mv ./-file.txt dest
(otherwise mv
thinks -file.txt
is an invalid option)
match all filenames ending in .png
rm *.png
(*.png
is called a “glob” and it’s handled by the shell so you can use it with any program!)
match .png
files in any subdirectory
rm **/*.png
(only works in zsh/fish)
match filenames starting with a dot
ls .*
(these aren’t included in * by default)
* gotcha: regular expressions
if you want to pass a regexp with a * to grep
:
grep '\s*test' file.txt
you need to quote it otherwise it will be treated as a glob
you can drag files from your GUI file manager to escape the filename
This only works if your terminal emulator supports it.
GNU ls will quote filenames with spaces in the name
$ ls
"julia's file.txt"
(properly quoted!)
you can check if you have this feature by running:
ls --quoting-style=shell
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!