[Shell] basic bash functions: wildcards and special symbols

Source: Internet
Author: User

/* Configure /*-------------------------------------------------------------------------------------------

@ Blackeye poet <www. chenwei. ws>

Optional --------------------------------------------------------------------------------------------*/

I. wildcard characters:

? MatchOneAny character.

* Match 0OneOrMultipleAny character.

[] Matching arbitrary in bracketsOneCharacter.

[-] Match anyOneCharacter,-indicates the range.

[^] Non-logical, matching is not in bracketsOneCharacter

 

The wildcard isUsed to match file namesOf:

Mkdir TMP;

Touch ABC;

Touch 0abc;

Touch ABCD;

Touch AABC;

 

Ls * ABC; # Matches ABC, 0abc, and AABC.

Ls * ABC *; # matching ABCD

Ls? ABC; # match 0ab, AABC

Ls [0-9] ABC; # match 0abc

Ls [^ 0-9] ABC; # match AABC

 

Ii. special symbols:

Single quotes (''): All special symbols in single quotes have no special meaning.

Double quotation marks (""): special characters in double quotation marks do not have special meanings. However"$", "'" And "\" have special meanings of "Call variable value", "reference command", and "Escape Character".

Backticks (''): The content enclosed by backticks isSystem commandsIn bash, It will be executed first. Like $ (), $ () is recommended, because it is very easy to read the quotation marks.

 

$ (): Used to reference system commands like anti-quotes.

 

#: In a shell script, the line starting with # represents a comment.

 

$: Value used to call a variableTo call the value of the variable name, you must use $ name to obtain the value of the variable.

 

\: Escape character. The special symbol following \ will lose its special meaning and become a common character. For example, \ $ outputs the "$" symbol, which is not a variable reference.

 

Name = www. chenwei. ws

Echo $ name # www. chenwei. ws

 

Echo '$ name' # $ name

Echo "$ name" # www. chenwei. ws

 

AB = 'date'

Echo $ AB # August 18, 2014 21:25:52 CST

Echo $ (date) # Monday, January 1, August 18, 2014 21:25:52 CST

 

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.