How do you read arguments in a shell program - $1, $2 ..?

Answer Posted / seshadri sethi

Shell script accepts parameters in following format…
$1 would be the first command line argument, $2 the second,
and so on
$0 is the name of the script or function

If your script has more than 9 params then accept in
following way…
${12} : 12th param
${18} : 18th param

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the slow execution speed of shells?

957


What is echo $shell?

803


What is the way to do multilevel if-else's in shell scripting?

933


What are the different types of commonly used shells on a typical linux system?

739


How do you debug a script?

759


What are the different types of variables used in shell script?

737


What is meant by dos operating system?

789


How do I save a powershell script?

761


Explain about return code?

800


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

919


Write a command sequence to find the count of each word?

725


What is shell variable?

687


What does echo $0 do?

739


Give some situations where typing error can destroy a program?

921


What is shell scripting?

762