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

467d72b12a52ef1031935b47ef25eab2.png

ibeautiful

$@与几乎相同$*,均表示“所有命令行参数”。它们通常用于简单地将所有参数传递给另一个程序(从而形成对该另一个程序的包装)。当您的参数中带有空格(例如)并$@用双引号引起来时,两种语法之间的差异就会显现出来:wrappedProgram "$@"# ^^^ this is correct and will hand over all arguments in the way#     we received them, i. e. as several arguments, each of them#     containing all the spaces and other uglinesses they have.wrappedProgram "$*"# ^^^ this will hand over exactly one argument, containing all#     original arguments, separated by single spaces.wrappedProgram $*# ^^^ this will join all arguments by single spaces as well and#     will then split the string as the shell does on the command#     line, thus it will split an argument containing spaces into#     several arguments.示例:呼叫wrapper "one two    three" four five "six seven"将导致:"$@": wrappedProgram "one two    three" four five "six seven""$*": wrappedProgram "one two    three four five six seven"                             ^^^^ These spaces are part of the first                                  argument and are not changed.$*:   wrappedProgram one two three four five six seven

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值