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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the command to find out today's date?

865


How to find all the files modified in less than 3 days and save the record in a text file?

853


What are the various stages of a linux process it passes through?

867


What is the equivalent of a file shortcut that we have a window on a linux system?

844


What is inside a seashell?

879


What does the sh command do?

834


Explain about echo command?

868


How does ls command work?

802


How to pass an argument to a script?

800


What is the use of "$?" Sign in shell script?

838


how to get part of string variable with echo command only?

786


How do you know which shell I am using?

804


What is meant by $1 in shell script?

743


Differentiate between ‘ and ” quotes.

823


What is gui scripting?

826