Globbing: File name wildcard (whole file name match, not part)
Match pattern: metacharacters
*: matches any character of any length
pa*, *pa*, *pa, *p*a*
PA, PAA, passwd
?: matches any single character
Pa??? PA, P?a, P?a?
PA, PAA, passwd
[]: matches any single character within the specified range
There are several special formats:
[A-z], [A-z], [0-9], [a-z0-9]
[[: Upper:]]: All uppercase letters
[[: Lower:]]: All lowercase letters
[[: Alpha:]]: All letters
[[:d Igit:]]: All numbers
[[: Alnum:]]: All letters and numbers
[[: Space:]]: all whitespace characters
[[:p UNCT:]]: All punctuation
PA[0-9][0-9], 2[0-9][0-9]
[^]: matches any single character outside the specified range
[^[:upper:]]
[^0-9]
[^[:alnum:]]
Exercise 1: Show all files or directories in the/var directory that start with L, end with a lowercase letter, and appear in the middle of an arbitrary character;
Ls-d/var/l? [[: Lower:]]
Exercise 2: Display a file or directory that starts with any digit in the/etc directory and ends in a non-numeric number;
Ls-d/etc/[0-9]*[^0-9]
Exercise 3: Display a file or directory that starts with a non-letter, followed by a letter and any character of any length, in the/etc directory;
Ls-d/etc/[^a-z][a-z]*
Exercise 4: Copy all files or directories that start with M and that end with a non-digit to the/tmp/magedu.com directory, in the/etc directory;
Cp-r/etc/m*[^0-9]/tmp/magedu.com/
Exercise 5: Copy the/usr/share/man directory, all the files or directories that begin with man, followed by a number, to the/tmp/man/directory;
Cp-r/usr/share/man/man[0-9]/tmp/man/
Exercise 6: Copy all files or directories that end with. conf and start with m,n,r,p in the/etc directory to the/tmp/conf.d/directory;
Cp-r/etc/[mnrp]*.conf/tmp/conf.d/
Shell Programming (iv) globbing