LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 03-06-2009, 06:32 AM   #1
ahtoot
LQ Newbie
 
Registered: Jun 2005
Posts: 22

Rep: Reputation: 1
Always pipe output of man to less


How do I always pipe the output of man to less? Currently the my man pages are formatted with more, and I always have to do the following:

Code:
man ls | less

Thanks.
 
Old 03-06-2009, 06:40 AM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Personally I'd do a shell script:
Quote:
#!/bin/bash
# usage m <ls, say>
man $1|less
exit 0
and save it as m

Code:
$ chmod a+x /path/m
and put in on your PATH. Maybe $1 in line 3 should be `echo "$1"` or something, God knows.

Last edited by lugoteehalt; 03-06-2009 at 06:45 AM.
 
Old 03-06-2009, 06:57 AM   #3
ahtoot
LQ Newbie
 
Registered: Jun 2005
Posts: 22

Original Poster
Rep: Reputation: 1
Thanks that worked very nicely.

I was wondering if I could still use the command man. I tried renaming m to man but that didn't work out. Would aliases work? I'm not sure how, if it's even possible, to place command line arguments into aliases.

Last edited by ahtoot; 03-06-2009 at 06:58 AM.
 
Old 03-06-2009, 07:32 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
No need for any of that.

Just set the 'PAGER' variable to 'less':
$ export PAGER=less
$ man man

Dave
 
Old 03-07-2009, 06:26 AM   #5
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by ahtoot View Post
Thanks that worked very nicely.

I was wondering if I could still use the command man. I tried renaming m to man but that didn't work out. Would aliases work? I'm not sure how, if it's even possible, to place command line arguments into aliases.
ilikejam is presumably correct, but for the purposes of argument or whatever it might be possible to alias a function, don't know:
Code:
f () { man `echo "$1"`|less; }
or whatever worked for the shell script.

Err....I'm a bit Mutley-esque about this: "Thanks that worked very nicely."....
 
  


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
Pipe output of find through rm? CelticBlues Programming 3 07-29-2008 04:09 AM
Redirecting sh output to a pipe elmafiacs Programming 0 05-10-2006 02:55 PM
how to pipe output from make BBB Programming 2 05-20-2005 07:14 AM
pipe xine output to file sohmc Linux - Software 0 01-01-2005 11:03 PM
Output truncated when using pipe tells Linux - General 1 12-16-2003 09:06 PM


All times are GMT -5. The time now is 05:33 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration