0

this is my piece of code:

##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

can someone please explain what is echo $@ doing here?

PS: 'ignore is a hidden argument'

sebastian-c
  • 15,057
  • 3
  • 47
  • 93
Surbhi Lal
  • 3
  • 1
  • 3
  • Surbhi: Kindly do not mention capital letters in your post/question. You should provide complete details of your question and then expected output too for a better guidance on your question, I hope this helps. – RavinderSingh13 Mar 20 '17 at 11:29

2 Answers2

0

@Surbhi: $@ denotes all of the parameters passed to the script. eg--> ./test.ksh test1 test2 then $@ will be equal to test1 test2.

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
0

If you run a shell script with arguments e.g:

./myscript goodbye cruel world

you can access those arguments within the script. In particular $@ gives you them all as they were typed - e.g. if myscript.sh is

#! /bin/sh
echo $@

the above command simply prints goodbye cruel world to the terminal

GavinBrelstaff
  • 3,016
  • 2
  • 21
  • 39