problem with KSH script: command line args

Hi I am executing a KSH script by passing command line arguments

example: Red Green Dark Red Blue

when I am splitting the arguments by using " "(Space) as delimiter

But the colour Dark Red is a single parameter. But it is getting splitted in between

How to avoid this. Please help Also the 3rd param can have any characters, special characters and symbols.

please help me with the code

:frowning:

You can try passing your command line args as follows

scriptname "Red"  "Green"  "Dark Red"  "Blue"

In your script $3 will give you "Dark Red"

As nareshprasannar says. But you only need the quotes around "Dark Red". The others work without. If you include special character, you'll have to use single quotation marks like 'Dark!* Red'.

Does the script really recognizes the command line argument 'Dark* Red' as a single parameter?

I think it will still takes 'Dark* as one argument and Red' as an other argument.

But I have not yet tried. will be replying back in few min

Very easy to test:

$> cat mach*
echo "1: $1"
echo "2: $2"
echo "3: $3"
echo "4: $4"
$> ./mach* red green 'dark !*red' blue
1: red
2: green
3: dark !*red
4: blue