->Title Page
->Intro
->Unix
-->Overview
-->File Structure
-->Online Manual
-->Basic Commands
-->Additional Commands
-->Login files
-->Special characters
->Wildcards
--->Redirection
--->Pipes
--->Quote characters
--->Others
-->Miscellaneous Tips
-->Things to try
->Vi editor
->Mirror sites
->Further reading

[ Up ]
[Prev][Home][Next]
[Author]

Unix ---> Wildcards

A number of characters are interpreted by the Unix shell before any other action takes place. These characters are known as wildcard characters. Usually these characters are used in place of filenames or directory names.


    *     An asterisk matches any number of characters
          in a filename, including none.
    ?     The question mark matches any single
          character.
    [ ]   Brackets enclose a set of characters, any
          one of which may match a single character
          at that position.
    -     A hyphen used within [ ] denotes a range of
          characters.
    ~     A tilde at the beginning of a word expands
          to the name of your home directory.  If you
          append another user's login name to the
          character, it refers to that user's home
          directory.
Here are some examples:

  1. cat c* displays any file whose name begins with c including the file c, if it exists.
  2. ls *.c lists all files that have a .c extension.
  3. cp ../rmt?. copies every file in the parent directory that is four characters long and begins with rmt to the working directory. (The names will remain the same.)
  4. ls rmt[34567] lists every file that begins with rmt and has a 3, 4, 5, 6, or 7 at the end.
  5. ls rmt[3-7] does exactly the same thing as the previous example.
  6. ls ~ lists your home directory.
  7. ls ~hessen lists the home directory of the guy1 with the user id hessen.

Site Statistics

1 Throughout this paper guy is assumed to be gender neutral unless otherwise stated.

t a y l o r@l i n u x b o x.c o m

© 1993-1998 Christopher C. Taylor