Although not a command, it is important to bring up wildcards in this
section on file commands. Wildcards can be used to save typing by
substituting a whole list of files for one typed instruction.
The asterisk (*) can be used to wildcard large parts of a filename,
while the question mark (?) is used to wildcard single characters in a name.
Let's use an example directory full of files:
file1, file2, ... file20, and file_a, file_b, ... file_z
if we did an ls, we'd get:
$ ls
file1 file14 file19 file5 file_a file_f file_k file_p file_u file_z
file10 file15 file2 file6 file_b file_g file_l file_q file_v
file11 file16 file20 file7 file_c file_h file_m file_r file_w
file12 file17 file3 file8 file_d file_i file_n file_s file_x
file13 file18 file4 file9 file_e file_j file_o file_t file_y
Now, some examples of ls using wildcards:
What files have only one character following the word 'file'?
$ ls file?
file1 file2 file3 file4 file5 file6 file7 file8 file9
What files contain the letter 'a'?
$ ls *a*
file_a
We can even use some regular expression syntax on our files. For
example: to get all files that have numbers after them:
$ls file[0-9]*
file1 file11 file13 file15 file17 file19 file20 file4 file6 file8
file10 file12 file14 file16 file18 file2 file3 file5 file7 file9