Article Title: Special characters in Bash. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. wildcard * Match any string of any length
? Match a single character
[...] Matches the characters in a single bracket,-,! in -,! It has special meanings, such:
$ Echo [a-z] *
Display the name of a file or directory with the first letter in the range of a-z
$ Echo [a, B] *
Displays the name of a file or directory whose first letter is a or B.
$ Echo [! A] *
Display the name of a file or directory whose initial character is not a (use! ,! Must be the first character after )! It can also be used with-and
In versions later than Bash 2.0, if the extglob option (shopt-s extglob) is enabled with shopt ), you can also extend the pattern expression (a pattern expression refers to words that contain one or more shell wildcards ):
* (Pattern [| pattern]...) zero or multiple occurrences of the matching mode
+ (Pattern [| pattern]...) one or multiple occurrences of the matching mode
@ (Pattern [| pattern]...) occurrence of a matching pattern
? (Pattern [| pattern]...) matches any pattern. it does not match *.
Repeated appearance of multiple modes or modes
! (Pattern [| pattern]...) and? Similarly, it does not include strings in the specified mode.
It should be noted that the definition of a pattern expression is recursive. each expression can contain one or more patterns, and the pattern expression can also be nested.
2. Special characters used for data or program control: Mainly include:
> (File) redirect output to file
> (File) redirects the output to the file and adds the content to the end of the existing file.
<(File) the input is redirected to the file.
; Command separator
| Pipeline operator, which redirects the output of one command to the input of another command
& Place the command and force the command to be executed in the background
''Command replacement, redirecting the output of one command to the parameters of another command
3. Special characters used for reference and escape: Escape character \ indicates that subsequent characters do not have special meanings or are not Shell functions,
In addition, Bash can also identify escape sequences in some C languages, such:
\ A response
\ B Rollback
\ E Escape
\ N line feed
\ R press enter
\ T tabulation
\ V tabulation
\ Backslash
\ Nnn octal ASCII code
\ Xnnn hexadecimal ASCII code
However, it must be referenced as follows:
$ 'String'
The quotition' and "reference a special character or blank-separated word to form a simple string.
The difference between the two is that the content in double quotation marks can be replaced by parameters and variables.
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