举个栗子
[root@skLinux rootCodeFiles]# vi specialvar.sh
#!/bin/sh
#usage sh specialvar.sh file1 file2 file3
echo '$# is :' $#
echo '$* is :' $*
echo '$? is :' $?
echo '$$ is :' $$
echo '$0 is :' $0
echo '$1 is :' $1
结果:
"specialvar.sh" [New] 9L, 161C written
[root@skLinux rootCodeFiles]# ls
firstShell.sh specialvar.sh weizhiVar.sh
[root@skLinux rootCodeFiles]# sh specialvar.sh filesk1 filesk2 filesk3
$# is : 3
$* is : filesk1 filesk2 filesk3
$? is : 0
$$ is : 7847
$0 is : specialvar.sh
$1 is : filesk1