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 @echo off?

560


What is a shell script? Can you name some of its advantages?

525


How would you compare the strings in a shell script?

543


What does path stand for?

638


Is powershell a language?

561






What is shift command in shell script?

522


What is shell company all about?

573


Write a shell script that adds two numbers if provided as the command line argument and if the two numbers are not entered throws an error message.

795


How do I debug a shell script?

560


How will you connect to a database server from linux?

553


What command needs to be used to take the backup?

528


What are "c" and "b" permission fields of a file?

559


How to check if the previous command was run successfully?

589


What language is shell scripting?

579


How do I run a .sh file?

613