What is the use of "shift" command in passing parameters?



What is the use of "shift" command in passing parameters?..

Answer / satchi

"shift" is useful when you need to access positional
parameters more than 9.

EX- execute a script to display 11th position parameter.

#./test.sh 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th
12th

shell scripts limits the access of arguments up to 9.to
over come this calculate the position of argument you want
to access and use shift to pull inside 9th countdown.

ex:
withen the script write "shift 2" before "echo $9"to
display 11th parameter.

withen the script write "shift 3" before "echo $9"to
display 12th parameter.

Is This Answer Correct ?    8 Yes 1 No

Post New Answer

More Shell Script Interview Questions

What does .sh file contain?

0 Answers  


If one dont know how to create a script then how he/she can use the QTP?

1 Answers  


How to write an Auto scripting for deleting old files using shell script and made a cron job to run on daily basis

1 Answers  


Why do we write bin bash in shell scripts?

0 Answers  


What is awk in shell script?

0 Answers  






Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script "reverse.sh"

1 Answers  


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

0 Answers  


Explain about sourcing commands?

0 Answers  


What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?

0 Answers  


What language is used in terminal?

0 Answers  


Differentiate between ‘ and ” quotes.

0 Answers  


what is this line in the shell script do ?#!/bin/ksh

5 Answers  


Categories