LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Always pipe output of man to less (https://www.linuxquestions.org/questions/linux-newbie-8/always-pipe-output-of-man-to-less-709592/)

ahtoot 03-06-2009 05:32 AM

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.

lugoteehalt 03-06-2009 05:40 AM

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.

ahtoot 03-06-2009 05:57 AM

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 03-06-2009 06:32 AM

No need for any of that.

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

Dave

lugoteehalt 03-07-2009 05:26 AM

Quote:

Originally Posted by ahtoot (Post 3466752)
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."....:D


All times are GMT -5. The time now is 06:28 PM.