I. general Variables
#/Bin/sh
Num = 2
Echo "this is the $ {num} Nd" # If the shell script language variables are tightly connected to letters, add.
Output result:
Ii. System Variables
$ #: Number of command line parameters for input scripts
$ *: All command line parameter values with spaces between each parameter value
$0: Command itself (shell file name)
$1: The First Command Line Parameter
$2: The second command line parameter
For example:
#/Bin/sh
Echo "Number of vars:" $ #
Echo "values of vars:" $ *
Echo "value of val0:" $0
Echo "value of val1:" $1
Echo "value of val2:" $2
Echo "value of val3:" $3
Echo "value of val4:" $4
Execution result:
Conclusion: The result shows that $0 is indeed the name of the file to be executed, $1, $2... is indeed a parameter passed in by the command line. It is worth noting that when the variable is not assigned a value, the content is blank, for example, $4.