# problem with KSH script: command line args

**URL:** <https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490>\
**Category:** Shell Programming and Scripting\
**Created:** [July 29, 2010, 7:30am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490 "2010-07-29T07:30:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemanth424](https://community.unix.com/letter_avatar/hemanth424/32/5_5575768a8748004e209b776fc1b2916d.png) [@hemanth424](https://community.unix.com/u/hemanth424)\
**Post date:** [July 29, 2010, 7:30am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490/1 "2010-07-29T07:30:28Z")

</div>

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

☹

---

<div class="post-metadata">

**Author:** ![nareshprasannar](https://community.unix.com/letter_avatar/nareshprasannar/32/5_5575768a8748004e209b776fc1b2916d.png) [@nareshprasannar](https://community.unix.com/u/nareshprasannar)\
**Post date:** [July 29, 2010, 7:55am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490/2 "2010-07-29T07:55:02Z")

</div>

You can try passing your command line args as follows

```nohighlight
scriptname "Red" "Green" "Dark Red" "Blue"

```

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

---

<div class="post-metadata">

**Author:** ![zaxxon](https://community.unix.com/user_avatar/community.unix.com/zaxxon/32/660_2.png) [@zaxxon](https://community.unix.com/u/zaxxon)\
**Post date:** [July 29, 2010, 8:13am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490/3 "2010-07-29T08:13:13Z")

</div>

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'.

---

<div class="post-metadata">

**Author:** ![hemanth424](https://community.unix.com/letter_avatar/hemanth424/32/5_5575768a8748004e209b776fc1b2916d.png) [@hemanth424](https://community.unix.com/u/hemanth424)\
**Post date:** [July 29, 2010, 8:25am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490/4 "2010-07-29T08:25:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zaxxon](https://community.unix.com/user_avatar/community.unix.com/zaxxon/32/660_2.png) [@zaxxon](https://community.unix.com/u/zaxxon)\
**Post date:** [July 29, 2010, 8:29am UTC](https://community.unix.com/t/problem-with-ksh-script-command-line-args/270490/5 "2010-07-29T08:29:32Z")

</div>

Very easy to test:

```nohighlight
$> 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

```
