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?

We have bash script ~/myscript shown below:
shift echo $2

We call this script:
~/myscript alpha beta gamma delta

What will we see?

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.



Leave a Reply 0

Your email address will not be published. Required fields are marked *