You probably know that file names that start with a .
, known as dotfiles,
will not show when you do ls
. What you may not know that the glob *
does not match dotfiles either.
This convention exists for historical reasons. In any Unix-like system you will
see two entries in all directories, .
and ..
. .
represents the current
directory and ..
represents the parent directory. They exist for ease of
navigation. In the early days of Unix somebody decided they were sick of seeing
these when doing ls
so quickly hacked up some code to hide any files which
started with a .
. Over time people realised this was a useful hack when
creating files you don't always want to see, for example rc-files.
You can see dotfiles with ls
by adding the --all
flag, -a
for short.
Slightly neater is the --almost-all
flag, or -A
for short, which will show
all your dotfiles but not show .
and ..
. You can match dotfiles with a glob
using .*
. .*
will show any file starting with a .
except .
and ..
.
They will be listed in alphabetical order ignoring all leading dots. This will
only match dotfiles so if you want to match all files you must combine two
globs together, * .*
.