Shell script Programming wildcard characters

Source: Internet
Author: User
Tags character classes lowercase uppercase letter

* matches any character of any length
? Match any single character
[0-9] Match all numbers
[] matches any single character within the specified range
[^] matches any single character outside the specified range
[WXC] matches any one of the characters in the list
[^WXC] matches characters other than all characters in the list
Pre-defined character classes: #man 7 glob
[[:d Igit:]]: Any number, equivalent to 0-9
[[: Lower:]]: Any lowercase letter
[[: Upper:]]: Any uppercase letter
[[: Alpha:]]: Any uppercase or lowercase letter (including case)
[[: Alnum:]]: any number or letter
[[: Space:]]: Spaces and tabs
[[:p UNCT:]]: punctuation

Matches any single character outside the specified range
[^[:upper]]
[^0-9]
[^[:alnum]]

Practice:
1. Display all files or directories with L, ending with a lowercase letter, and with at least one digit in the middle of the/var directory
Ls/var/l*[0-9]*[[:lower]]
2. display files or directories that start with any digit in the/etc directory and end with a non-digit
LS/ETC/[0-9]*[^0-9]
3, display/etc/directory with a non-letter beginning, followed by a letter and any other arbitrary length of any character file or directory
ls/etc/[^[:alpha:]][[:alpha:]]*
4. Display all files or directories in/etc that start with a non-numeric end of M
LS/ETC/M*[^0-9]
5. Display all files or directories ending with. D in the/etc directory
Ls/etc/*.d
6. Display the files or directories with the end of. conf and beginning with m,n,r,p in the/etc directory
Ls/etc/[mnrp]*.conf

Shell script Programming wildcard characters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.