0

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

3
Contributors
4
Replies
6
Views
9 Years
Discussion Span
Last Post by chris5126
0

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?

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.