"Shell" wildcard characters and special symbols

Source: Internet
Author: User

--from "Brother Bird's Linux private dish"

There is also a very useful feature in Bash's operating environment, which is the wildcard character (wildcard)! It's even easier for us to use bash to process data! Below is a list of some common wildcard characters:

Symbol Significance
* Represents "0 to infinity" of any character
? Represents "must have a" any character
[ ] Also means "there must be a character in parentheses" (not any character). For example [ABCD] represents "must have a character, may be a, B, C, d these four any one"
[ - ] If a minus sign is inside the brackets, it represents "all characters in the code order." For example [0-9] represents all numbers between 0 and 9, because the language encoding of the numbers is continuous!
[^ ] If the first character in the brackets is an exponential sign (^), that means "invert selection", for example [^ABC] means that there must be a character, as long as the other characters of non-A, B, C are accepted.

Next use the wildcard character with LS to find the file name to see:

Example one: Find the file name that starts with cron under/etc/ ll-d/etc/cron*    <== Plus-D is to show only the table of contents Example two: Find the file name "exactly five letters" under/etc/ <== because? There must be one, so five of them? That's right. example three: Find out the file name of the/etc/under the filename contains the number of the file name <== Remember the brackets around the left and right side of the * example four: Find out the/etc/, the file name starts with a non-lowercase file name: <== Note the left side of the bracket is not * Example Five: Copy the files found in sample four to/tmp CP-A/etc/[^a-z]*/tmp         

In addition to wildcards, the following special symbols are available in the bash environment:

Symbol Content
# notation: This is most commonly used in script, as a description! None of the data is running after
\ Skip symbol: Revert a "special character or wildcard" to a normal character
| Pipeline (pipe): Delimited two pipeline command definition (the latter two sections are introduced);
; Continuous command Release delimiter: definition of continuity command (note!) Not the same as the pipeline command)
~ User's home directory
$ Take the variable leader: that is, the variable that needs to be added before the variable to replace the value
& Job Control: Turn the command into a background job
! The meaning of "not" in the sense of logical operation!
/ Directory symbols: path-delimited symbols
, >> Data flow redirection: output-oriented, "replace" and "accumulate", respectively
<, << Data flow redirection: Input orientation (these two are for the next section)
‘ ‘ Single quotes, no function of variable substitution
" " function with variable substitution!
` ` Two "'" in the middle of the command can be run first, also use $ ()
( ) The beginning and end of the child shell in the middle
{ } In the middle for a combination of command blocks!

These are the special symbol sinks that are common in bash environments! In theory, your "file name" try not to use the above characters!

"Shell" wildcard characters and special symbols

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.