Hi All,

How to read the following command line values for a in my shell script?

./test.sh -a file1 file2 file3

i know we can use getopt() but i am geting only first value(file1)..

Any help appreciated

-jujose

The rest of the filenames are in $*
or use $1 and shift to process them one at a time.

The rest of the filenames are in $*
or use $1 and shift to process them one at a time.

$* means all the agrumnets after -a ??

if my requirment is like test.sh -a file1 file2 -c file3 file4

wht would be the solution?

The solution would be to read the manual page for getopt again to see if you can tell it that -a has two parameters for example.

If not, them I guess you're stuck with the old fashioned way of doing it all yourself.

you could use $1 $2 $3 etc so

test.sh -a file1 file2 -c file3 file4

$1=-a
$2=file1
$3=-c
etc etc each argument would go into the next $(number) but you would have to have some pretty complex testing to look for flags or files getop() wld be better