Shell Symbols
| $# | csh, sh | Number of arguments to script |
| $* | csh, sh | Arguments to script |
| $@ | sh | Original arguments to script |
| $- | sh | Flags passed to shell |
| ${array[@]} | leads to each element of the array being treated as a separate shell-word | |
| ${array[*]} | results in a single shell-word with all of the elements of the array separated by spaces (or whatever the first character of IFS is) |
Difference between $@ and $*
$@
./test_shell "w1 w2" w3 w4
$@ will be
w1 w2
w3
w4
$*
$@ will be
w1 w2
w3
w4
$*
./test_shell "w1 w2" w3 w4
$* will be
w1 w2 w3 w4
$* will be
w1 w2 w3 w4
评论
发表评论