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

Write down the syntax for all the loops in shell scripting.

0 Answers  


What is a beat in a script?

0 Answers  


what are command line arguments? what is the need of those?

1 Answers   Flipkart,


Is shell script a programming language?

0 Answers  


Suppose you execute a command using exec, what will be the status of your current process in the shell?

0 Answers  






How to rename all the files in a folder having specific extension? Example: I have some files with extension (.txt) in a folder name 'Test'. I have to rename all the .txt files in a test and its subdirectories to .my extension.

15 Answers   Interra IT,


Is shell a part of kernel?

0 Answers  


Explain about sourcing commands?

0 Answers  


Explore about environment variables?

0 Answers  


how is the oppurtunities for unix in the software

1 Answers  


How can you find out how long the system has been running?

0 Answers  


How do I stop script errors?

0 Answers  


Categories