4.1.5. Filenames

As we said before, files or directories starting with ‘.’ are hidden and are not shown in an normal listing. There are also other characters which have special meaning for the shell and cannot be used in file or directory names 1:

< > ‘ | ? [ ] * ” ; and $ and - as first character of a name.

The ‘.’ can be used as part of a non-hidden filename if it is not the first character. In fact this is normally used to give a filename an extension according to the type of file. In contrast with Windows, the extension doesn’t define the type of file, although some programs expect a certain extension.

The space character can be used in a filename, but it should be avoided. It can sometimes give strange results in a lot of commands because the shell interpretes the space as a separation character (see here).




Exercises


  1. In the directory /data/tccm/linux_bash/strange there are some files containgin non-standard characters.

    • see what files are there by

      ls -l /data/tccm/linux_bash/strange/

    • try to list the individual files, e.g.

      ls -l /data/tccm/linux_bash/strange/<brol

      Can you explain what is happening ?

    • go to the directory and list the files again withou the pathname, e.g.

      ls -l <brol

      Do you get the same results as before ? Can you explain this ?

    • Is there a solution to previous problems ?


1

In fact, it is possible to use this characters, but they should be avoided. See exercises.