# Help with basic scripting!

**URL:** <https://community.unix.com/t/help-with-basic-scripting/264169>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [April 19, 2010, 9:27pm UTC](https://community.unix.com/t/help-with-basic-scripting/264169 "2010-04-19T21:27:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarovarc](https://community.unix.com/letter_avatar/sarovarc/32/5_5575768a8748004e209b776fc1b2916d.png) [@sarovarc](https://community.unix.com/u/sarovarc)\
**Post date:** [April 19, 2010, 9:27pm UTC](https://community.unix.com/t/help-with-basic-scripting/264169/1 "2010-04-19T21:27:24Z")

</div>

Hey I have to create a unix script that when run uses the 'man' command to print out the command information of commands passed as arguments. I have the basic pseudo code, but I don't know how to implement a loop. Any help is greatly appreciated. Cheers.

```nohighlight
short-manual <ls cc pwd>
for(i=1;i<max_argument;i++)
do
  man argument
  echo -------------
  i=i+1
end loop 

```

Can someone direct me to a syntax for this please.

---

<div class="post-metadata">

**Author:** ![Nila](https://community.unix.com/user_avatar/community.unix.com/nila/32/1187_2.png) [@Nila](https://community.unix.com/u/Nila)\
**Post date:** [April 20, 2010, 12:06am UTC](https://community.unix.com/t/help-with-basic-scripting/264169/2 "2010-04-20T00:06:46Z")

</div>

Try this,

```nohighlight
#!/bin/sh
if [$# -eq 0]
then
        echo "Please Give positional parameters"
        exit
else
        for i in $*
        do
                man "$i"
        done
fi

```

---

<div class="post-metadata">

**Author:** ![glev2005](https://community.unix.com/letter_avatar/glev2005/32/5_5575768a8748004e209b776fc1b2916d.png) [@glev2005](https://community.unix.com/u/glev2005)\
**Post date:** [April 20, 2010, 5:26pm UTC](https://community.unix.com/t/help-with-basic-scripting/264169/3 "2010-04-20T17:26:57Z")

</div>

Also, If I am not mistaken, you need two parentheses in your for loop (used in your sudo code).

```nohighlight
for((i=1;i<$#;i++))

```

---

<div class="post-metadata">

**Author:** ![treesloth](https://community.unix.com/letter_avatar/treesloth/32/5_5575768a8748004e209b776fc1b2916d.png) [@treesloth](https://community.unix.com/u/treesloth)\
**Post date:** [April 23, 2010, 12:45pm UTC](https://community.unix.com/t/help-with-basic-scripting/264169/4 "2010-04-23T12:45:50Z")

</div>

I don't know for sure what the goal of this is, but if you want to simply display all of the page, as opposed to simply opening it in a less-type interface, you might do:

```nohighlight
 man "$i" | col

```

For that matter, "col" is a convenient way to save the pages to another file, or to pipe to a mail command, etc.
