Provide detailed answer with examples below 1 How will you p
Provide detailed answer with examples below:
1) How will you pass and access arguments to a script in Linux?
2) What is the significance of $#
Solution
1.You can access passed arguments with $n where n is the argument number - 1, 2, 3, ... Use variable $1,
$2..$n to access argument passed to the function.
For example the syntax can be written as follows:
name()
{
arg1=$1
arg2=$2
command on $arg1
}
2. $# it indicates the total number of parameters that are present in the shell. This sign can be used in linux in the functions or syntax to use all the parameters
