for these things, the gods are already in the chest, but there are some just contact Linux , Unix people like these systems may not be familiar with these variables, so I'll share them with you today. What problem can add QQ Group, we discuss together -- Ops tribe:348384728
To make it easier for everyone to understand, write a simple script that will explain the meaning of each variable later.
# Touch Test
# VI Test
The script reads as follows:
#!/bin/sh
echo "number:$#"
echo "Scname:$0"
echo "First: $ $"
echo "Second:$2"
echo "Argume:[email protected]"
echo "Show Parm list:$*"
echo "Show Process id:$$"
echo "Show Precomm stat: $?"
Save exit
Assigning script execution Permissions
# chmod +x Test
Execute script
#./test AA BB
Number:2
Scname:./test
First:aa
Second:bb
ARGUME:AA BB
Show Parm LIST:AA BB
Show Process id:24544
Show Precomm stat:0
By displaying the results you can see:
$# is the number of arguments passed to the script
$ is the name of the script itself
$ is passed to the Shell the first parameter of a script
$ is passed to the Shell The second argument of a script
[email protected] is a list of all parameters passed to the script
$* is to display all parameters passed to the script in a single string, unlike positional variables, where parameters can exceed 9 a
$$ is the current process that the script runs ID number
$? is to display the exit status of the last command, 0 indicates no error, other indicates an error
This article is from "Old Gao Blog" blog, please be sure to keep this source http://12092502.blog.51cto.com/12082502/1943049
Linux variable $#,[email protected], meaning of $0,$1,$2,$*,$$,$?