< Zurück | Inhalt | Weiter >

1.3.3 Filenames

Filenames in Linux can be quite long and composed of virtually any character. Practically speaking, however, you’re much better off if you limit the length to something reasonable, and keep to the alphanumeric characters, period, and the underscore (“_”). That’s because almost all the other punctuation characters have a special meaning to the shell, so if you want to type them, you need to escape their special meaning, or suffer the results of unintended actions.


Filenames are case sensitive—upper- and lowercase names are different. The files ReadMe.txt and readme.txt could both be in the same directory; they are distinct files.

Avoid using spaces in filenames, as the shell uses whitespace to delineate between arguments on a command line. You can put a blank in a name, but then you always have to put the name in quotes to refer to it in the shell.

image

To give a filename more visual clues, use a period or an underscore. You can combine several in one filename, too. The filenames read_me_before_you_begin or test.data.for_my_program may be annoyingly long to type, but they are legal filenames.



NOTE

The period, or “dot,” in Linux filenames has no special meaning. If you come from the MS-DOS world, you may think of the period as separating the filename from the extension, as in myprogrm.bas where the filename is limited to eight characters and the extension to three characters. Not so in Linux. There is no “extension,” it’s all just part of the filename.

You will still see names like delim.c or Account.java, but the .c or

.java are simply the last two characters or the last five characters, respective- ly, of the filenames. That said, certain programs will insist on those endings for their files. The Java compiler will insist that its source files end in .java and will produce files that end in .class—but there is no special part of the file- name to hold this. This will prove to be very handy, both when you name your files and when you use patterns to search for files (see below).