Rote memorization in the shell

Source: Internet
Author: User

One, the shell quotes

1. "", double quotation marks (do not retain the full content, such as encountered $, anti-quotes, \ etc will execute the corresponding shell)

echo "Today is `date`"   -> Today is Wed Aug  

2. Single quotation mark (full retention content)

echo "Today is `date`"   -> Today is `date`  

3. "Anti-quotation mark (the shell inside the inverted quote will execute)

echo `date`   -> Wed Aug 3 05:59:19 GMT 2011  
Second, the shell variable description
$$Shell本身的PID(ProcessID)$!Shell最后运行的后台Process的PID$?最后运行的命令的结束代码(返回值)$-使用Set命令设定的Flag一览$*所有参数列表。如"$*"用 "" 括起来的情况、以"$1 $2 … $n"的形式输出所有参数。[email protected]所有参数列表。如"[email protected]"用 "" 括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。$#添加到Shell的参数个数$0Shell本身的文件名$1~$n添加到Shell的各参数值。$1是第1参数、$2是第2参数

A simple script can explain the meaning of each variable.

#!/bin/shecho "number:$#"echo "scname:$0"echo "first :$1"echo "second:$2"echo "argume:[email protected]"

Output:

number:2scname:./variablefirst: aasecond:bbargume:aa bb

By displaying the results you can see:
$# is the number of arguments passed to the script
The name of the script itself
$ $ is the first parameter passed to the shell script
$ $ is the second parameter passed to the shell script
[Email protected] is a list of all parameters passed to the script

Attach a Vim learning guide

Https://coolshell.cn/articles/5426.html

Rote memorization in the shell

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.