7 – Seeing The World As The Shell Sees It
current working directory) before the echo command is executed. When the enter key is
pressed, the shell automatically expands any qualifying characters on the command line
before the command is carried out, so the echo command never saw the “*”, only its ex-
panded result. Knowing this, we can see that echo behaved as expected.
Pathname Expansion
The mechanism by which wildcards work is called pathname expansion. If we try some
of the techniques that we employed in our earlier chapters, we will see that they are really
expansions. Given a home directory that looks like this:
[me@linuxbox ~]$ ls
Desktop ls-output.txt Pictures Templates
Documents Music Public Videos
we could carry out the following expansions:
[me@linuxbox ~]$ echo D*
Desktop Documents
and:
[me@linuxbox ~]$ echo *s
Documents Pictures Templates Videos
or even:
[me@linuxbox ~]$ echo [[:upper:]]*
Desktop Documents Music Pictures Public Templates Videos
and looking beyond our home directory:
[me@linuxbox ~]$ echo /usr/*/share
/usr/kerberos/share /usr/local/share
68