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

$*
./test_shell "w1 w2" w3 w4

$* will be
w1 w2 w3 w4

评论

此博客中的热门博文

Openwrt路由器上配置shadowsocks透明代理+gfwlist(PAC)

Configure shadowsocks transparent proxy + gfwlist(PAC) on OpenWRT Router

Using Haproxy + shadowsocks (ha + ss) to setup multi ss backend and load balance