"Go" Bash introduction and wildcard characters, extended wildcard Shopt-s Extglob

Source: Internet
Author: User

http://www.rhce.cc/?p=1005

When we execute some commands, a lot of the commands are provided by Bash . If we want to know if a command is a command built by Bash , we can use the type

Bash built-in command:Bash wildcard extension wildcard Rhce

Type

Fc

Alias

If you want our aliases to continue to work, then we're going to write to the. BASHRC Bash wildcard extended wildcard character Rhce

There are a lot of shell built-in commands, and if we want to close a command, then we can use

Enable : The ability to turn a built-in command on or off

* and?
* matches all characters of any length (cannot match hidden files)

LS *---> displays all non-hidden files under the current directory

?: matches a character, is a not 0 , nor multiple, can only match one

[] : Match one character, not 0 , nor multiple

Number:[0-9]- Yes to the meaning

Letter: [A-z] [a-z] [a-za-z]

Class:

[[: Alnum:]]: All letters and numbers

[[: Alpha:]] represents English uppercase and lowercase letters A- z

[[: Blank:]] represents both the space bar and the [Tab] key

[[:d Igit:]] : Represents a number [0-9]

[[: Space:]]

[[: Lower:]] : Represents a lowercase letter [A-z]

[[: Upper:]] : denotes uppercase letters [A-z]

These are some of the features that bash has given us. These features we can selectively turn on or off

Set-o

1. Noclobber is now off , which means we can now perform the overlay (>)

Set-o function

set +o function If you want to shut down.

Set +o Noclobber


Turn off wildcard function: set-o noglob

To close a wildcard :

Shell Options can change the Shell 's operating mode

Shell Options ==> shopt

Deletion is not the time to delete hidden files

* does not match hidden files

Directly delete, is not delete hidden files, because * cannot match hidden files at all

Now want to match:shopt to change the shell 's Properties

Shopt-s feature: Enable a feature

Shopt-u function; Turn off a feature

Shopt-s Dotglob

Shopt-u Dotglob

Extension of file name:

In Linux , the sdx( The value range of x is a- z), if the number of hard disks is too large. Sdz, now there are a few hard drives, how to express? Sdaa, Sdab, Sdac....sdaz, SDBA, SDBB.

There are a lot of hard drives in the computer, I want to do all the hard work (not the partition) now. How do I express all the hard drives?

If you say sdx, SDXY?

SDA[A-Z]? ---> Sdax can't match SDA SDB .

Sda? --Sdab Sda2, and doesnot want to match the partition so sda2 cannot display

If you want to do this, we can use extended wildcard characters .

If you want to display more than one letter:

Shopt-s Extglob; LS sd+ ([a-z])

To find out that there are multiple letters behind the SD, so that the SD behind the number of those all drained .

With Extglob, you can match more patterns.

? (): The value in parentheses can be 0 or 1

? meaning that the contents of the parentheses in the following brackets appear 1 Times or 0 Times

*(): The value in parentheses can be 0 or more

+(): The value in parentheses can be 1 or more

@(): Matches one occurrence in parentheses

To find out the mp3 or txt files that appear after ABC . Is once, cannot be many times

So abc.txt.txt There is no match, because it appears in two times txt.

! (): Opposite to @() : After-school questions think for yourself

Shopt-p

* means match all characters, but if you match all other characters outside of a class, it can be globignore

* match all, no matter what character you are.

I don't want to match the numbers now, that's sda*, the * to represent all the characters except the numbers.

GLOBIGNORE=SDA*[0-9]

* when matching, to Remove the value represented by the Globignore

"Go" Bash introduction and wildcard characters, extended wildcard Shopt-s Extglob

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.