来自 bash 手册页:
"$*"
is equivalent to"$1c$2c..."
, wherec
is the first character of the value of theIFS
variable.
"$@"
is equivalent to"$1" "$2"
...
有没有 "$@"
不能代替 "$*"
的例子?
最佳答案
我最喜欢的用途是替换字段分隔符。
$ set -- 'My word' but this is a bad 'example!'
$ IFS=,
$ echo "$*"
My word,but,this,is,a,bad,example!
还有其他替换定界符的方法,但 IFS 和 "$*"
通常是最简单的方法之一。
关于bash - bash 中 "$*"有哪些用例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30082852/