PrepAway - Latest Free Exam Questions & Answers

What will we see?

We have bash script ~/myscript shown below:
shift echo $2
We call this script:
~/myscript alpha beta gamma delta
What will we see?

PrepAway - Latest Free Exam Questions & Answers

A.
alpha

B.
beta

C.
gamma

D.
delta

Explanation:
shift shifts all arguments to the left (meaning arg1 becomes arg2, arg2 becomes arg3, …), so after the shift the 2nd argument becomes gamma.

One Comment on “What will we see?

  1. Diego Perfeito says:

    The script/exercise is not funcional. The correct:
    We have bash script ~/myscript shown below:
    shift
    echo $2
    We call this script:
    ~/myscript alpha beta gamma delta

    See,ok = C.gamma

    The error is “echo $2” with parameter in shift.
    shift only reduce one in left order.




    0



    0

Leave a Reply