linuxdot.org
 
 
 

Contents | Previous | Next

Wildcards

Any time a filename is used, you can replace parts of the filename or all of it with wildcards (also called shell patterns). Any sensible combination you can think of can be used. You can also use wildcards to specify directories.

Warning:

When copying, moving, or removing files with wildcards, it's often wise to include the -i (interactive) option, to avoid mishaps.

Wildcard Description
* Represents any amount of characters, including none.
? Each '?' represents any single character.
[...] Represents a group of specified characters.
[!...] Represents anything but the specified characters.

Consider the following directory listing:

cartoon.png  ex10.html  ex1.html  ex2.html  ex3.html  index.html  logo.png


rm e*
Would remove: ex10.html  ex1.html  ex2.html  ex3.html


ls *.png
Would list: cartoon.png  logo.png


rm ex?.html
Would remove: ex1.html  ex2.html  ex3.html (but not ex10.html)


rm ex??.html
Would remove: ex10.html


rm ex[13]*
Would remove: ex10.html  ex1.html  ex3.html


ls ex[1-3].html
Would list: ex1.html  ex2.html  ex3.html


mv ex[!1]* ..
Would move up one directory: ex2.html  ex3.html

Contents | Previous | Next

 
Copyright © 1998-2002 Linuxdot.org.
Linux ® is a registered trademark of Linus Torvalds.