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 $@ mean bash?

0 Answers  


how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example

4 Answers  


What is a shell environment?

0 Answers  


How do I run a powershell script?

0 Answers  


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

0 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  


What are the different types of shell scripting?

0 Answers  


Explain how you Automate your application using Shell scripting.

0 Answers   MAHINDRA,


What are the different shells available?

3 Answers  


What are the advantages of bash over all other shells?

1 Answers  


How would you compare the strings in a shell script?

0 Answers  


What is the use of "test" command?

2 Answers  


Categories