unixshell脚本中$@的含义
这是我的一段代码:unixshell脚本中$@的含义,unix,Unix,这是我的一段代码: ##Checking swapspace if ignore option chosen will force creation of swap space echo ; echo "[INFO]: Validating Swap space " swapspace=`swapon -s|tail -1|awk '{print $3/1024}'` if [ ${swapspace} -le 500 ]; then echo $@ |grep ignore&g
##Checking swapspace if ignore option chosen will force creation of swap space
echo ; echo "[INFO]: Validating Swap space "
swapspace=`swapon -s|tail -1|awk '{print $3/1024}'`
if [ ${swapspace} -le 500 ]; then
echo $@ |grep ignore>/dev/null
if [ `echo $?` -eq 0 ]; then
echo "[WARNING]: Swap space is below minimum requirement get the same fixed :${swapspace}
Proceeding with WorkAround. PLEASE GET IT FIXED AT THE EARLIEST"
dd if=/dev/zero of=/swapfile bs=2G count=4
chmod 0600 /swapfile; mkswap /swapfile; swapon /swapfile
export SWAPFLAG=1
else
echo "[ERROR]: Swap space is below minimum requirement get the same fixed :${swapspace}"
export SWAPFLAG=2
fi
fi
有人能解释一下echo$@在这里做什么吗
PS:“忽略是一个隐藏参数”@Surbhi:
$@
表示传递给脚本的所有参数。例如-->/test.ksh test1 test2
,如果运行带有参数的shell脚本,则$@
将等于test1 test2
,例如:
./myscript goodbye cruel world
您可以在脚本中访问这些参数。特别是,$@
会按键入的方式为您提供所有内容-例如,如果myscript.sh
是
#! /bin/sh
echo $@
上面的命令只是将
再见残酷世界
打印到终端Surbhi:请不要在您的帖子/问题中提到大写字母。您应该提供问题的完整细节,然后提供预期输出,以便更好地指导您的问题,我希望这会有所帮助。