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
How to get the last line from a file using just the terminal?
What is a batch file used for?
What does chmod do?
What are the advantages of using shell scripts?
Is shell a scripting language?
What does the sh command do?
How do I run a shell script in powershell?
Which is better perl or shell scripting?
Write down the syntax for all the loops in shell scripting.
Can you write a script to portray how set –x works?
Write down the syntax of "for " loop
How do I stop script errors?
What happens on a system call?
What is the use of "$?" Sign in shell script?
What is a program shell?