If you want to assign the value of var to the variable lcount, you can do so
as follows:
Command Environment
lcount=$var pdksh and bash
set lcount=$vartcsh
Positional Parameters
It is possible to pass options from the command line or from another shell
script to your shell program.
These options are supplied to the shell program by Linux as positional
parameters, which have special names provided by the system. The first
parameter is stored in a variable called 1 (number 1) and can be accessed by
using $1 within the program. The second parameter is stored in a variable
called 2 and can be accessed by using $2 within the program, and so on. One
or more of the higher-numbered positional parameters can be omitted while
you’re invoking a shell program.
Understanding how to use these positional parameters and how to access and
use variables retrieved from the command line is necessary when developing
more advanced shell programs.
A Simple Example of a Positional Parameter
Consider this example: If a shell program mypgm expects two parameters—
such as a first name and a last name—you can invoke the shell program with
only one parameter, the first name. However, you cannot invoke it with only
the second parameter, the last name.
Here is a shell program called mypgm1, which takes only one parameter (a
name) and displays it on the screen:
Click here to view code image
#!/bin/sh
#Name display program
if [ $# -eq 0 ]
then
echo "Name not provided"
else