Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$@和有什么区别$*?为什么它们具有相同的值但当我设置"$@"为时却不同?"$*"IFS|
$@
$*
"$@"
"$*"
IFS
|
$@和之间的区别$*:不带引号(不要这样做!),根本没有:两者相等$1 $2.... 使用双引号,$@将每个元素扩展为参数:$1 $2...,同时$*扩展为合并为一个参数的所有元素:$1c$2c...(其中 c 是 IFS 的第一个字符)。你几乎总是想要$@. 数组也是如此:${myarray[@]}
$1 $2
$1
$2
$1c$2c...
${myarray[@]}