Shell Basics (i)

Source: Internet
Author: User

Shell Basics (i)

* represents 0 or more arbitrary characters

? represents an arbitrary character

# Comment symbol, comment description meaning, that is, the content behind the # Linux ignored, or in the shell script to explain the symbol, explain the explanation, used in the text that needs to note the beginning of the word

\ de-ideographic character, return the following special symbol (for example *) to ordinary characters, examples are as follows:

#ls-D test\*

Unable to access test*: No file or directory

| Pipe character to drop the result of the preceding command to the command following the symbol.

It is important to note that the following commands, not all commands, are generally used for document operations, such as

Cat,less,head,tail,grep,cut,sort,wc,uniq,tee,tr,split,sed,awk and so on.

Where Grep,sed,awk is the tool that must be mastered for regular expressions.

Example: #cat testb.txt |wc-l

0

wc-l is used to calculate how many rows a document has.

$ Special symbol

Used for the identification symbol in front of the variable, $PATH $HOME

And! Together, #!$ the last parameter in the previous command, which is the last item in the command, such as path, file name, and so on.

; Special symbols

You can run multiple commands on one line

#ls-D test*; Touch test111; Ls-d test*

Test1 Test2

Test1 Test2 test111

~ Special Symbols

User's home directory, if Root is/root, ordinary user/home/username

& Special symbols

Put the command in the background to execute, need to add this symbol. This is typically used when the command runs longer.

#sleep &

[1] 3260

#jobs

[1]+ Running Sleep &

> >> 2> 2>> < redirect symbol

> Redirection

>> Chasing heavier orientation

2> Error Redirection

2>> Error Append redirect

< reverse redirection

Reverse redirect redirects the contents of the right document to the left side of the command, such as # Wc-l < 1.txt

When running a command error, the error message will be entered into the current screen, if you want to redirect to a text, you need to use 2> and 2>>.

#ls AAA

No file or directory

#ls AAA 2>/tmp/error

#cat/tmp/error

No file or directory

[] brackets

The middle is a combination of characters that represents either of the intermediate characters. The parentheses can only be exact matches and cannot be used *

#ls-D test*

Test1 test2 test3 Testa testb TESTC

#ls-D Test[1-3]

Test1 test2 Test3

#ls-D TEST[1A3]

Test1 Test3 Testa

#ls-D test[0-9]

Test1 test2 Test3

#ls-D test[0-9a-z]

Test1 test2 test3 Testa testb TESTC


This article is from the "Wu Fei" blog, please be sure to keep this source http://wutengfei.blog.51cto.com/10942117/1908043

Shell Basics (i)

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.