UNIX Tutorial Four

4.1 Wildcards

The characters * and ?

The character * is called a wildcard, and will match against none or more character(s) in a file (or directory) name. For example, in your unixstuff directory, type

$ ls list*

This will list all files in the current directory starting with list....

Try typing

$ ls *list

This will list all files in the current directory ending with ....list

The character ? will match exactly one character.
So ls ?ouse will match files like house and mouse, but not grouse.
Try typing

$ ls ?list

4.2 Filename conventions

We should note here that a directory is merely a special type of file. So the rules and conventions for naming files apply also to directories.

In naming files, characters with special meanings such as / * & % , should be avoided. Also, avoid using spaces within names. The safest way to name a file is to use only alphanumeric characters, that is, letters and numbers, together with _ (underscore) and . (dot).

File names conventionally start with a lower-case letter, and may end with a dot followed by a group of letters indicating the contents of the file. For example, all files consisting of C code may be named with the ending .c, for example, prog1.c . Then in order to list all files containing C code in your home directory, you need only type ls *.c in that directory.

4.3 Getting Help

On-line Manuals

There are on-line manuals which gives information about most commands. The manual pages tell you which options a particular command can take, and how each option modifies the behaviour of the command. Type man command to read the manual page for a particular command.

$ man

Just like you did when using less, press the [space-bar] if you want to see another page, type [q] if you want to quit reading, [/] if you want to search for some text and [n] for moving to the next occurrence of the searched text.

This type of keyboard shortcut consistency across Unix commands is extremely common and helps users to accelerate their knowledge on how to use the command line.


* match any number of characters
? match one character
man command read the online manual page for a command