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