$#: Number of parameters passed to script
$*: Displays all parameters passed to the script in a single string. Unlike positional variables, this option argument can exceed 9
$$: The current process ID number of the script run
$! : The process ID number of the last process running in the background
$@: With $ #相同, but with quotes and returns each argument in quotation marks
$-: Displays the current options used by the shell, the same as the SET command
$? : Displays the exit status of the last command. 0 indicates no errors, and any other value indicates an error.
Copy Code code as follows:
#!/bin/sh
#param. Sh
# $: File Full path name
echo "Path of script: $"
# Get file name using basename command file path
echo "Name of script: $ (basename $)"
# $1: Parameter
echo "Parameter 1: $"
# $: Parameter 2
echo "Parameter 2: $"
# $: Parameter 3
echo "Parameter 3: $"
# $: Parameter 4
echo "Parameter 4: $"
# $: Parameter 5
echo "parameter 5: $"
# $#: Number of parameters passed to script
echo "The number of arguments passed: $#"
# $*: Show all parameter Contents I
echo "Show all arguments: $*"
# $: ID number of the script currently running
echo "Process ID: $"
# $?: Return code
echo "Errors: $?"
Enter./param.sh Hello World
Copy Code code as follows:
[Firefox@fire shell]$./param.sh Hello World
Path of script:./param.sh
Name of script:param.sh
Parameter 1:hello
Parameter 2:world
Parameter 3:
Parameter 4:
Parameter 5:
The number of arguments Passed:2
Show All Arguments:hello World
Process id:5181
errors:0