Shell metacharacters and shell internal variables

Source: Internet
Author: User
Shell metacharacters and shell internal variables
Shell metacharacters

> Prog> file redirects the standard output to the file
> Prog> file: attaches the standard output to the file.
<Prog <file: Get standard input from File
| P1 | P2 uses the P1 standard output as the P2 standard input
<String here document: the standard input is read from here document until a string is displayed.
* Match zero or multiple characters in the file name
? Match any single character in the file name
{ABC} matches any characters in the ABC range in the file name, for example, 0-9 or a-Z.
Command Terminator, for example, P1; P2 indicates that P1 is executed first, and then P2 is run
& Command Terminator, similar to;, but not equal to p1
'...' Run the command in... and the output result replaces '...'
(...) Execute the command in the sub-shell...
{...} Execute the command in... in the current shell (rarely used)
$1, $2, etc. $0... $9 represents the parameters of the shell file
$ Variable shell variable value
$ {Variable} variable value to avoid confusion during text connection
// C uses the C character as the character, but the/line break is invalid.
'...' As text, no replacement
"..." In..., $, '...' and/are replaced, and then... is used as the text.
# Annotation
Variable = value: variable value
P1 & p2 run P1; if successful, run P2 again
P1 | P2 run P1; if it fails, run P2 again
_____________________________________________________________________
Shell internal variables

$ # number of parameters, starting from 0
$ * all shell parameters
$ @ similar to $ *, for more information, see Article http://bbs.chinaunix.net/viewthread.php? Tid = 218853 & extra = & page = 7
$-Options for shell
$? Returned value of the last command
$ $ shell process identifier
$! Use the process identifier of the last & started command
$ Home CD default parameter
$ ifs parameter to separate the two-dimensional table of words
$ mail file, when it changes, You have mail... you have never used this ^ _ ^
$ path to search for the Directory table
$ PS1 prompt string. The default value is $

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.