Wildcards
You can use wildcards to substitute all or part of a filename. This is useful if you want to manipulate a large number of files but you don't want to specify each file name.
You can use the * symbol to represent zero or more characters. Some examples:
mv *.c programs/
lpr essay*.ps
more hw*
You can use the ? symbol to represent any single character. Some examples:
cp ?may95 may/
enscript paper?.txt
less assign?
You can match any single character a list or range by enclosing them in []. Some
examples:
rm [bchmr]at
lpr exam[1-9].ps
cat final[123]
You can match a string by enclosing them in {}. Some examples:
mv {may,june,july,august}1995 summer95/
enscript lecture{CA,NV,OR}.txt
ls notes.{comp,pdp,csci}
You can also combine wildcards. Some examples:
cp {prog,prgrm,program}*.? programs/
lpr {assign,hw,project}[123].ps
ls student*[xyz].{z,zip,gz,Z}
Last updated:
October 16, 2008