Special positional parameter variables in 1.shell
$: Gets the file name of the currently executing shell script, including the script path if the execution script contains a path
$n: Gets the nth parameter of the currently executing shell script, n=1..9, which represents the file name of the script when n is 0, or if n is greater than 9, enclosed in curly braces
For example ${10}, the parameters are separated by a space
$#: Gets the total number of parameters that are followed by the currently executing shell script
$*: Gets the arguments of all parameters of the current shell script, without quotation marks and [email protected], if the $* with double quotes, such as "$*", it means that all parameters are treated as
As a single string, equivalent to "$ $ $"
[Email protected]: Get all parameters of the current shell script arguments, without quotation marks and $* the same, plus double quotes, such as "[email protected]", it means that all the parameters are treated as a different
Independent string, equivalent to "$" "$" "$" "..." This is the best way to pass multiple parameters to other programs because it preserves all inline
Any whitespace in each parameter.
Special state variables in the 2.shell process
$?: Gets the execution state return value that executes the last instruction (0 for success, not 0 for failure), commonly used
$$: Gets the process number (PID) of the currently executing shell script, not commonly used
$!: Gets the process number (PID) of the last process working in the background, not commonly used
$_: Gets the last parameter of the command or script executed before this, not commonly used
3.bash shell built-in variable command
The bash shell contains some built-in commands. These built-in commands are invisible in the table of contents and are provided by the shell itself. The common internal commands are:
Echo, eval, exec, export, read, shift.
Echo: Output information on the screen
Command format: Echo args
Parameters:
-N: Do not wrap output content
-E: Parsing escape characters
Escape characters:
\ n: Line break
\ r: Enter
\ t: Tab (TAB)
\b: Backspace
\v: Portrait tab
Eval:
Command format: eval args
Function: When the shell program executes to the Eval statement, the shell reads the parameter args, combines them into a new command, and then executes
Exec:
[Email protected] script]# vim exec.sh
[email protected] script]# cat exec.sh
#!/bin/bash
EXEC </script/1.txt
While Read line
Do
Echo $line
Done
Echo OK
[[email protected] script]# SEQ 5 > 1.txt
[email protected] script]# cat 1.txt
1
2
3
4
5
[Email protected] script]# sh exec.sh
1
2
3
4
5
Ok
This article is from "It look" blog, please be sure to keep this source http://jinlong.blog.51cto.com/3276088/1954810
shell--special position parameter variables and common built-in variables