This command will list any file starting with "a" and ending with
"n"
ls a*n
Command line autocompletion. This is a great command line
feature--I use the [Tab] key a lot to save on typing. It makes it brisk to
deal with long and complicated filenames. For example using such a filename on
the command line is really not a problems, if I use autocompletion:
dir Eurosong 2000 Olson Brothers - Fly on the wings of love
(denmark).mp3
I just type
dir Eu[Tab]
and if there are no other files starting with "Eu", the rest of
the filename is automatically typed for me. Otherwise, I would have to look at
my choices (which are printed for me) and type one or two more characters to
make the filename unambiguous.
Problems with weird filenames. Most of these problems can be
solved using autocompletion. Additionally, to manipulate files with names that
contain metacharacters, I may use a pair of ' ' (two apostrophes), so that the
metacharacters are quoted and therefore the shell does not interpret their
meaning. For example, to rename a file my file* (contains space and
asterisk), I would issue:
mv 'my file*' filename_without_weird_characters.txt
Please note that I use a pair of ' (apostrophes) for quoting. Quoting with
a pair of " " (quotation marks) is generally weaker than
quoting with ' ' . If you use " (quotation marks) some
metacharacters may get interpreted.
Following UNIX tradition, on Linux, one may create files with names
contaning almost any character, including non-printable (control) characters.
Those are very infrequent, but if you encounter such a file, it can make you
feel really weird. I would rename such a file using a carefully positioned
metacharacter. I would use ls first to try if my action indeed targets the
desired file, and then rename the file:
ls -l myfile*y.html
mv myfile*y.html myfile.html
As an example of the perhaps weirdest problems that you might face when
using non-recommended characters in a filename, try creating a file with a
name starting with a dash and then remove it--there seems to be no way to do
it (because a dash normally introduces command options). E.g., the
command
dir > -junk