LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 05: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, 06:06 AM   #2
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
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, 09: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, 09:22 AM   #4
stlouis
Member
 
Registered: Jul 2006
Location: Sault Ste. Marie, Ontario
Distribution: RedHat, CentOS, Fedora Core, Gentoo, Slackware
Posts: 63

Rep: Reputation: 16
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, 09:25 AM   #5
stlouis
Member
 
Registered: Jul 2006
Location: Sault Ste. Marie, Ontario
Distribution: RedHat, CentOS, Fedora Core, Gentoo, Slackware
Posts: 63

Rep: Reputation: 16
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, 09: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 05:34 PM
simple shell script sycamorex Linux - Newbie 2 03-16-2006 06:00 PM
Simple shell script mikz Linux - General 1 02-24-2005 07:18 AM
a simple shell script Warchief Programming 1 07-31-2003 05:01 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:54 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
Open Source Consulting | Domain Registration