且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

$@ 在 shell 脚本中是什么意思?

更新时间:2022-06-18 04:30:50

$@ 是传递给脚本的所有参数.

$@ is all of the parameters passed to the script.

例如,如果您调用 ./someScript.sh foo bar 那么 $@ 将等于 foo bar.

For instance, if you call ./someScript.sh foo bar then $@ will be equal to foo bar.

如果你这样做:

./someScript.sh foo bar

然后在 someScript.sh 里面引用:

umbrella_corp_options "$@"

这将被传递给 umbrella_corp_options,每个单独的参数用双引号括起来,允许从调用者那里获取带有空格的参数并将它们传递.

this will be passed to umbrella_corp_options with each individual parameter enclosed in double quotes, allowing to take parameters with blank space from the caller and pass them on.