Wednesday, March 30, 2011

Filename Substitution with Wildcards

Wildcards
*  0 or more characters
?  1 character
 
Command typed Meaning
ls *display all files
ls *.shdisplay all shell scripts
ls go*display all files starting with the letters 'go' and any possible combination of other characters afterwards
ls go??display all files starting with 'go' and two unknown characters
ls go[abcd]display all files starting with 'go' and one more character of either 'a', 'b', 'c', or 'd'
ls go[a-d]display all files starting with 'go' and one more character in the 'a' to 'd' range
ls go[a-dA-D]display all files starting with 'go' and one more character in the 'a' to 'd' range or the 'A' to 'D' range
ls go[!a-d]display all files starting with 'go' and one more character not in the 'a' to 'd' range
ls [a-d]*display all files starting with 'a', 'b', 'c', and 'd' and any other character -- or no other characters

No comments:

Post a Comment