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