Help with basic scripting!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with basic scripting!
# 1  
Old 04-19-2010
Help with basic scripting!

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.

Code:
short-manual <ls cc pwd>
for(i=1;i<max_argument;i++)
do
  man argument[i]
  echo -------------
  i=i+1
end loop

Can someone direct me to a syntax for this please.

Last edited by Scott; 04-23-2010 at 01:48 PM.. Reason: Added code tags
# 2  
Old 04-20-2010
Try this,

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

# 3  
Old 04-20-2010
Also, If I am not mistaken, you need two parentheses in your for loop (used in your sudo code).

Code:
for((i=1;i<$#;i++))

# 4  
Old 04-23-2010
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:

Code:
 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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Basic Shell Scripting

Hi All, I am a newbie to shell scripting. I am trying to something like this. #!bin/bash cd /u01/app/oracle/ # then start the process ./opmnctl startall Can someone help me with this requirement. Help is very much appreciated. Thanks Venkat Please use code tags next time for... (10 Replies)
Discussion started by: venkat8439
10 Replies

2. Shell Programming and Scripting

which is the Very basic certification on unix shell scripting?

Hi, I am very new to this forum, can any one tell me which is the very basic certification on unix shell scripting? please give me an advice on this. (1 Reply)
Discussion started by: Manjesh
1 Replies

3. Shell Programming and Scripting

basic scripting syntax

In bash scripts please can someone tell me if the below is the correct syntax for comparing integers and strings; for integers - if ;then for strings - if ; then Thanks Calypso (4 Replies)
Discussion started by: Calypso
4 Replies

4. UNIX for Dummies Questions & Answers

basic scripting help

I would like to know: 1. How is `command` used? 2. How is '$command' used? For example, a script file that checks for apache tomcat processes that I created has the following lines: test set suffix=` grep "6.0.18"` set command = `ps -ef $suffix` echo $command //?? hoping this... (2 Replies)
Discussion started by: jon80
2 Replies

5. Shell Programming and Scripting

basic shell scripting question

If I did indeed grep something out of it, why woudln't $result show nothing? When I do $? , it does show success... What is the proper syntax so that $result shows actual thing it's grepping out? result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" >dev/null` #echo... (3 Replies)
Discussion started by: convenientstore
3 Replies

6. Shell Programming and Scripting

Shell scripting basic doubt

Hi, I have a script called sam.sh which consists of a single echo statement like this #/usr/bin/ksh echo "Mani" I changed the mode for the script by giving chmod a+x sam.sh. If I want to execute the scrpt by just giving the name at the command line "sam.sh", what should I necessarily do?... (3 Replies)
Discussion started by: sendhilmani123
3 Replies

7. Shell Programming and Scripting

What is a good place to learn basic shell scripting? Thanks!

See the title. Originally wasn't going to type anything but I need a message of at least 10 characters! :cool: (2 Replies)
Discussion started by: deutchap6verse5
2 Replies
Login or Register to Ask a Question