Wildcards in Filenames
UNIX allows wildcards in almost all commands -- it is actually a feature of the shell. Caution: UNIX also uses the wildcard characters in pattern matching, but the meaning is only similar, not identical.
UNIX Wildcards
? any single character, except a leading dot
* zero or more characters, except a leading dot
[ ] defines a class of characters ( - for range, ! to exclude)
UNIX Examples:
[abc]?? 3 character filename beginning with "a", "b", or "c".
[1-9][A-Z] 2 character filename starting with a number, and ending with an uppercase letter.
[!A-Z]?? 3 character filename that does not begin with an uppercase letter.
*e[0-9]f any file ending with "e", a single number, and "f".
Examples:
UNIX allows wildcards in almost all commands -- it is actually a feature of the shell. Caution: UNIX also uses the wildcard characters in pattern matching, but the meaning is only similar, not identical.
UNIX Wildcards
? any single character, except a leading dot
* zero or more characters, except a leading dot
[ ] defines a class of characters ( - for range, ! to exclude)
UNIX Examples:
[abc]?? 3 character filename beginning with "a", "b", or "c".
[1-9][A-Z] 2 character filename starting with a number, and ending with an uppercase letter.
[!A-Z]?? 3 character filename that does not begin with an uppercase letter.
*e[0-9]f any file ending with "e", a single number, and "f".
Examples:
*------ Any Number of character
? ------single Character
[ijk] ---- single character either i,j or k
[x-z] ---- range
[!ijk]
[!x-z]
chap01 chap02 chap03 chap04
ls chap0*
echo *
ls chap?
ls chap??
matching dot :
ls .???* i want to know
2) ls chap0[124]
ls chap0[1-4]
Escaping:
For example file with chap*
ls chap\* this one also
escaping space:
cd my\ Document
No comments:
Post a Comment