LL5 – Wildcards & Help


As before, you are responsible for all previous Linux coursework and for researching the commands below in more depth using Wikipedia and the built-in Linux man pages.  You will also be taking screen shots, pasting them into your LastnameFirstnameLL5.odt file and submitting (uploading) them in BB.

To begin, please navigate to your ciss100/FirstnameLastname directory created in previous labs.

5.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, 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

Exercise 5a

Take a screenshot and paste it into your document

5.2 Filename conventions

We should reinforce here that a directory is merely a special type of file. So the rules and conventions for naming files also apply 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 the _ (underscore) and . (dot).  My preference is camel case notation and you should know what this is by this point.

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 although Linux does not manage extensions to the same extent as Windows and Mac OS (less management improves OS efficiency). 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.

Beware: some applications give the same name to all the output files they generate.  For example, some compilers, unless given the appropriate option, produce compiled files named a.out. Should you forget to use that option, you are advised to rename the compiled file immediately, otherwise the next such file will overwrite it and it will be lost.

5.3 Getting Help

On-line Manuals

We already introduced this but for completeness, there are on-line manuals which give 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.

For example, to find out more about the wc (word count) command, type

$ man wc


$ whatis wc

gives a one-line description of the command, but omits any information about options etc.  As a result this provides a nice quick intro of the command

When you are not sure of the exact name of a command, we can use apropos

$ apropos keyword

will give you the commands with “keyword” in their manual page header. For example, try typing

$ apropos copy # zowie hunh 🙂

Exercise 5b

Take and paste a screenshot into your .odt document


* match 0 or more characters
? match one character
man command read the online manual page for a command
whatis command brief description of a command
apropos keyword match commands with keyword in their man pages

Leave a Reply