Explanation of the meaning of shell variables $#, $@, $0, $1, $2, $HOME

Explanation of the meaning of shell variables $#, $@, $0, $1, $2, $HOME in linux:
Variable description:

$HOME View the user's home directory
$$
Shell's own PID (ProcessID)
$!
The PID of the background process that Shell runs last
$?
The end code (return value) of the last running command
$
-List of Flags set with the Set command
$*
List of all parameters. For example, when "$*" is enclosed in """, all parameters are output in the form of "$1 $2 ... $n".
$@
A list of all parameters. For example, when "$@" is enclosed in """, all parameters are output in the form of "$1" "$2" … "$n".
$#
The number of parameters added to the shell
$0
The file name of the shell itself
$1~$n
are added to each parameter value of the shell. $1 is the first parameter, $2 is the second parameter

#!/bin/bash
printf "The complete list is %s\n" "$$"
printf "The complete list is %s\n" "$!"
printf "The complete list is %s\n" "$?"
printf "The complete list is %s\n" "$*"
printf "The complete list is %s\n" "$@"
printf "The complete list is %s\n" "$#"
printf "The complete list is %s\n" "$0"
printf "The complete list is %s\n" "$1"
printf "The complete list is %s\n" "$2"

Results of the



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326084981&siteId=291194637