linux[Base]-10-command-line wildcard [01]

Source: Internet
Author: User

command-line wildcard characters

command-line wildcard characters:

An example:

[Email protected] ~]# LS/DEV/SDA

/dev/sda

[Email protected] ~]# ls/dev/sda1

/dev/sda1

[email protected] ~]# ls/dev/sda2

        /dev/sda2

[Email protected] ~]# Ls/dev/sda3

Ls:cannot access/dev/sda3:no such file or directory

The role of wildcards here is you're not sure how many partitions, partition numbers, he can help you determine

* Match 0 or more characters

? Match any single character

[0-9] numbers within the matched range

[ABC] matches the given character

Instance:

[Email protected] ~]# ls/dev/sda*

/dev/sda/dev/sda1/dev/sda2

[Email protected] ~]# LS/DEV/SDA?

/dev/sda1/dev/sda2

[[email protected] ~]# ls/dev/sda[0-9]

/dev/sda1/dev/sda2

[[email protected] ~]# LS/DEV/SD[ABC]

/dev/sda

[Email protected] ~]# LS/DEV/SD[ABC]?

        /dev/sda1/dev/sda2

[Email protected] ~]# ls/dev/sd[abc]*

        /dev/sda/dev/sda1/dev/sda2

In addition Bash supports many special character extensions:

\ (backslash) escapes a single character later

"(single quote) to escape all characters

"" (double quote) variable is still in effect

"(anti-quote) EXECUTE command statement

Variable takes effect:

[Email protected] ~]# price=5

[Email protected] ~]# echo "Price is $Price"

Price is 5

But if you want to show the price as $ $, and it conflicts with the variable, it's time to use the escape character \ Backslash

[[email protected] ~]# echo "Price is $ $Price"

Price is 6892Price

[Email protected] ~]# echo "Price is \$ $Price"

Price is $

Use single quotation marks to escape all characters

[Email protected] ~]# echo ' Price is \$ $Price '

Price is \$ $Price

Use "to execute command statements

[[email protected] ~]# echo ' uname-a '

Linux msl23-linux.com 3.10.0-123.el7.x86_64 #1

SMP Mon May 5 11:16:57 EDT x86_64 x86_64 x86_64 gnu/linux

[[email protected] ~]# echo ' uname-r '

3.10.0-123.el7.x86_64

linux[Base]-10-command-line wildcard [01]

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.