LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 01-24-2008, 06:56 AM   #1
jCash
Member
 
Registered: Sep 2006
Posts: 57

Rep: Reputation: 15
create a shell script to do simple man lookup


I can do this command in linux shell:
Quote:
man -p $MYAPP_HOME/man WhateverIWantToSearchString
But I just don't want to keep typing. I want to have a shell script that would be called myman.sh and then I can just pass the "WhateverIWantToSearchString".

So it would be:
Quote:
myman WhateverIWantToSearchString
Can someone give me an insight into this?

thanks.
 
Old 01-24-2008, 07:06 AM   #2
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Why don't you just put those man files in with the rest? Or else put all those man files in a single man folder in your home directory and include it in a manpath set in your .bash_profile ?
 
Old 01-24-2008, 10:04 AM   #3
jCash
Member
 
Registered: Sep 2006
Posts: 57

Original Poster
Rep: Reputation: 15
having separate myman script, prevents man page conflicts. How do you write a simple script the take command arguments and append it? This should be one liner.
 
Old 01-24-2008, 10:22 AM   #4
stlouis
Member
 
Registered: Jul 2006
Location: Sault Ste. Marie, Ontario
Distribution: RedHat, CentOS, Fedora Core, Gentoo, Slackware
Posts: 63

Rep: Reputation: 15
This is what you are looking for I believe;

#!/bin/bash
#
# "myman" script

mpath=/path/to/your/man/pages

myfile=$1

man $mypath/$myfile


Or something quite similar.
 
Old 01-24-2008, 10:25 AM   #5
stlouis
Member
 
Registered: Jul 2006
Location: Sault Ste. Marie, Ontario
Distribution: RedHat, CentOS, Fedora Core, Gentoo, Slackware
Posts: 63

Rep: Reputation: 15
I forgot to mention, once the little script is written, you must ensure it has execute priviledges and accessible from your system PATH, unless your are ready to specify the path to it each time...

usage:

myman <file to view>


NOTE: You do NOT have to specify the PATH to the file, as it is defined by the mpath, or whatever you name it variable... Just type if the file you want to view, and voila, it's there...


Jeff
 
Old 01-24-2008, 10:51 AM   #6
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
You are probably rather looking for something like

Code:
#!/bin/bash

man -p $MYAPP_HOME/man "$@"
But for something as simple as this, an alias is probably the better solution (add the definition to your ~/.bashrc or ~/.bash_aliases or somesuch):
Code:
alias myman='man -p $MYAPP_HOME/man'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help getting started simple simple shell script dhonnoll78 Programming 6 12-17-2007 06:34 PM
simple shell script sycamorex Linux - Newbie 2 03-16-2006 07:00 PM
Simple shell script mikz Linux - General 1 02-24-2005 08:18 AM
a simple shell script Warchief Programming 1 07-31-2003 06:01 AM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM


All times are GMT -5. The time now is 06:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration