Linux wildcard characters

Source: Internet
Author: User

When using command lines, there is a lot of time to find the files you need, such as LS find. S h e l L provides a complete set of string pattern matching rules, or meta-characters, when S-H-L encounters the above characters, it treats them as special characters rather than ordinary characters in the file name, so that the user can use them to match the corresponding file names, which I understand can be called wildcards.

wildcard characters and regular expressions are different, simple: wildcard is used to match, the regular expression is used for matching strings, in the text Filter tool, are used regular expressions, such as awk,sed, etc., is for the content of the file. Wildcard characters are used in filenames, such as finding FIND,LS,CP, and so on. Second, the shell has a difference between the wildcard and the regular expression, "" is generally a wildcard character (is the shell itself extraction processing), "is usually a regular expression (the shell will pass the data to other command processing).

The following is a wildcard character in the usual sense:

* matches any string in the file name, including an empty string.

? Matches any single character in the file name.

[...] Matches any of the characters contained in [].

[!...] Match [] Non-exclamation! The character after.

Such as:

All strings starting with 5* 5

All strings ending in 5

A. A string with a second-to-last character of 5

[0-9] all characters with numbers

[1] or 2

[!0-9] is not a numeric character

ls/etc/[!a-n]*.conf lists files in the/etc/directory that do not start with the letters A through n and end with. conf

ls/etc/[a-n]*.conf lists files in the/etc/directory that begin with the letters A through n and end with. conf

ls/bin/[ck]* lists filenames that begin with C or K

Linux 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.