Stanford University School of Earth Science
 
Home
News
New Users
Policies
Email
Network File Server
Web Hosting
Get Help
Net Connections
Macintosh
Windows PC
Unix/Linux System
Pangea Server
School Resources
Using Unix
   Overview
   Documentation
   Accounts
   Using the Shell
   Using X-Windows
   File Manipulation
   Net Commands
   Editing Text
   Formatting Text
   Printing
   Filters & Utilities
   Programming

Wildcard specification of filenames

Last revision August 3, 2004

Table of Contents:

  1. The Unix file system
  2. The directory tree
    • Wildcard specifications
  3. File ownership and permissions
  4. Files as units
  5. Examining file contents
  6. Other commands
  7. Standard Files and Data Pipes
 

These apply to the C-shell. All but the tilde apply to the Bourne shell as well.

Certain special characters can be used as wildcards when typing filenames as part of commands. These wildcards can expand to or match several possible filenames. These expansions and matches are done by the shell, before it passes the argument list to the command, so they work the same for all commands that want filename arguments.

*
(asterisk) - matches any string of characters, including the null string. Example:
      ls a*
matches any filename that starts with a, including just a by itself.

?
(question mark) matches any single character. That is, it means any character may be in its place, but there must be one, and only one, character there. Example:
      ls a?b
matches any three-character filename that begins with a and ends with b.

[...]
(list of characters enclosed in square brackets) matches any one of the characters enclosed in the brackets. Example:
      ls a[bcdefg]
matches any two-character filename that begins with a and ends with either b or c or d , etc.

~
(tilde) is an abbreviation for home directory. By itself or just before the slash character at the beginning of a pathname, it refers to the current user's home directory. When used to prefix a user name, it refers to the home directory of that specified user. Examples:
      ls ~
shows all files in your home directory.

ls ~/prog
shows all files in the sub-directory prog in your home directory.

cd ~bruce
changes your working directory to be bruce's home directory.

<--Previous Overview Next-->

 


Comments?

Stanford University    |