Description: The shell parameter, as the name implies, is passed to the shell script, we can use some parameters in the sh scripts.sh parameter parameter +1 parameter +2 of the way to execute.
The format for getting parameters within a script is: $n n represents a number,
The first argument to execute script (corresponding to the above parameter)
$ $ is the second parameter to execute a script, and so on ...
Here's a simple chestnut:
1. First edit a simple script, as follows:
[Email protected] 01]# vim 1.sh
#!/bin/bash
echo "I am $1,you is."
2. Execute the following script
[[Email protected] 01]# sh 1.sh
I am, you is.
[email protected] 01]# cat 1.sh
#!/bin/bash
echo "I am $1,you is."
3. Add the corresponding parameters behind the script
[Email protected] 01]# sh 1.sh Lili Leilei
I am Lili,you is leilei.
The shift command shifts the positional parameters to the left with the shift command.
For example, the Shift 3 command will now change the original $4 to $
Will turn the original $ $ now into a $ $ and so on,
will be the original $, $, $ discarded, no move.
The shift command with no parameters is equivalent to shift 1.
A simple example of shell-pass arguments