Learning materials for Linux-universal characters and special symbols

Source: Internet
Author: User
Tags uppercase character

Universal characters and special symbols

Because of the use of some universal characters in Bash, and with special symbols to make better use of the instructions (such as the most commonly mentioned formal notation Regulare Express)! Below we list some commonly used universal characters and special symbols:

Symbol content

* Universal characters, representing one or more characters (or numbers)

? Universal characters, which represent a single letter

# annotations, which are most commonly used in script, are treated as descriptions!

\ Skips symbols, restores "special characters or universal characters" to normal characters

| Delimit two lines of command definition;

; Definition of continuity command (note!) Not the same as the pipeline command)

~ User's Home directory

$ that is the variable that needs to be added before the variable is replaced by the value

& Turn Directives into work under the background

! The meaning of "not" in the sense of logical operation!

/path-delimited symbols

>> output guidance, respectively, is "replace" and "accumulate"

' Single quotes, no function of variable substitution

"Has the function of variable substitution!"

"Two" ' "in the middle is a command that can be executed first!

() in the middle for the beginning and end of the child shell

[] in the middle for the combination of characters

{} In the middle is a combination of command blocks!

Combining key Execution Results

Ctrl + C terminates the current command

Ctrl + D input End (EOF), such as when the message ends;

Ctrl + M is the Enter!

Ctrl + S Pauses the output of the screen

Ctrl + Q To restore the output of the screen

Ctrl + U under prompt character, remove the whole column of commands

Ctrl + Z "pause" current command


Of the above universal characters, the most commonly used is *,?, [] and '! Let's mention a few simple examples:

[Test @test test]# ls test* <== that * represents the back no matter how many characters are accepted (no word Fuye accept!) )

[Test @test test]# ls test? <== that? Represents "must" to be followed by "one" character

[Test @test test]# ls Test??? <== that??? On behalf of "must answer three" characters!

[Test @test test]# CP test[1-5]/tmp <== will test1, Test2, Test3, test4, test5 if present, copy to/tmp

[Test @test test]# cd/lib/modules/' uname-r '/kernel/drivers <== the content "will be executed first"!

The above few examples are quite interesting! Especially at the back of the two! It is important to note that [] inside "represents only one character" but the range can be 1-5, so that if we allow "as long as the file name contains at least one uppercase character", you can copy the file, you can do this:


CP *[a-z]*/tmp

Very interesting, huh?! ^_^

In addition, the "Instructions" in the "inside" will be executed first, that is to say:

The system performs the uname-r first to find out the result of the output;

Add the results to the catalog to perform CD functions!

It's great!! These basic functions need to be special to understand a bit!


--------------------------------------------------------------------------------


How to release a continuous instruction:

Here we need to mention a few important information, we have just mentioned that two instructions are written together, you can write:

Command1; Command2

Using semicolons "; "To separate, the meaning of this semicolon, representing whatever command1 execution results, Command2 will be executed!" So if I were two related instructions, the first Command1 if the execution result has an error, the second one is not executed, can you do that? Sure, just use the following two links:

Command1 && Command2

Command1 | | Command2

Remember our previous variable content, that? What does it mean? Yes, is to represent the previous execution of the content of the command is error-free, if there is an error callback to 1, no error on the callback to 0, you can pass the echo $? To inquire to know! Then && is the representative, when the Command1 execution results return value of 0, that is, there is no error message, then the Command2 will start execution, and | | On the contrary, when the Command1 has the wrong message, the Command2 will execute! For example, my system does not/vbird this directory, so executing ls/vbird should have an error message, so what does the bottom three command string show?

[Root @test root]# Ls/vbird; LS/

[Root @test root]# ls/vbird && ls/

[Root @test root]# Ls/vbird | | LS/


Try to see Yo!


Learning materials for Linux-universal characters and special symbols

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.