Hi Unixers,
In a shell script i found the following statements
mline='grep\^ 1111 emaster.dbf
set -- $mline
The first statement searches the emaster.dbf file for the code 1111 and ifit finds any such line it gets that line and stores it in mline.
But iam getting little bit confusion with second statemnt.I know that the set command is used to set the command line arguments.
Then what is the purpose of -- .
Suppose if mline=1111 Ravi M IT ORACLE
then
$1=1111 $2=Ravi $3=M $4=IT $5=ORACLE.
Did you try the man pages ? They are a very good source of information.
man sh says
-- If no arguments follow this option, then the positional
parameters are unset. Otherwise, the positional parame-
ters are set to the args, even if some of them begin with
a -.
See this
[/tmp]$ cat try.sh
#! /bin/sh
arg="first second third"
if [ $# -eq 3 ] ; then
echo $1
echo $2
echo $3
fi;
set -- $arg
echo $1
echo $2
echo $3
[/tmp]$ ./try.sh 12 23 34
12
23
34
first
second
third
[/tmp]$ ./try.sh
first
second
third
[/tmp]$