$0, $1, $2,...
,對應如下:
/path/to/scriptname opt1 opt2 opt3 opt4 ... $0 $1 $2 $3 $4 ...
[dywang@dywmac zzz]$ cat sh04.sh #!/bin/bash echo "The script name is ==> $0" [ -n "$1" ] && echo "The 1st paramter is ==> $1" || exit 0 [ -n "$2" ] && echo "The 2nd paramter is ==> $2" || exit 0 [ -n "$3" ] && echo "The 3th paramter is ==> $3" || exit 0
[dywang@dywmac zzz]$ sh sh04.sh abc 123 cde The script name is ==> sh04.sh The 1st paramter is ==> abc The 2nd paramter is ==> 123 The 3th paramter is ==> cde
[dywang@dywmac zzz]$ sh sh04.sh abc 123 The script name is ==> sh04.sh The 1st paramter is ==> abc The 2nd paramter is ==> 123