Path expansion in the shell

Source: Internet
Author: User
Tags glob

Glob extension

In the path extension in the shell, there are several glob involved:

? Match any single character

* Match 0 to more characters

[Set] matches any one of the characters in the set, such as [0-9], matches any number

[!set] matches any character that is not in set, such as [!0-9], matches any non-numeric character

It is important to note that:

In set-based glob, if you want to match-, you can put-in front of the set, or placed behind the set, such as [-a0-9] matches any character-,a,0 to 9;

If you want to match!, you need to escape

If the match is unsuccessful, the original string is preserved, such as LS g*, and if the match cannot be made, the shell will error: g* No such file or directory

Brace extension

1 Basic formats for brace extensions

preamble{comma-delimited string}postscript, where premable and PostScript are optional, such as:

A{b, C}d, extended to ABD,ACD

2 brace extensions can be nested

A{b{c,d},e}f, extended to ABCF,ABDF,AEF

3 brace extensions can be used to represent a contiguous set of letters or numbers:

{0..4} extended to 0 1 2 3 4

The above glob extension and brace extension, both of which can be used in the shell's path extension

Path expansion in the shell

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.