Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Search 'man' pages UNIX
I recently found out that when viewing a man page you (via "man [command]") you can search it by using forward-slash. ie, / beewee would find the first occurrence of "beewee" and by hitting "n" it's like "Find Again" and it finds the next one.

I also found out about hitting "?" to see all the cool options that are possible while viewing a man page.

[Editor's note: I had no idea ... and of course (and this time I swear I checked!) there's no mention of these features in "man man".]
  • Currently 2.86 / 5
  You rated: 4 / 5 (7 votes cast)

Search 'man' pages | 15 comments | Create New Account
Click here to return to the 'Search 'man' pages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Do a man on ed
Authored by: Spunkmeyer on Mar 28, '02 12:07:48AM

Man is basically a front end to ed (the unix line text editor). So are vi, sed and others. You'll find lots of cool things you can do with man, vi, etc. by learning ed. It's lso handy for editing commands in the command line buffer.

[ Reply to This | # ]
man uses more by default
Authored by: yobananaboy on Mar 28, '02 12:16:36AM

man uses more for pagination by default. you can change
this by setting the environment variable PAGER.


% setenv PAGER less
% man less

The man page for less describes the navigation commands.
For example, to search backwards type ?search_term

The search term is a regular expression. man ed to learn about
regular expressions.

[ Reply to This | # ]
Re: man uses more by default
Authored by: sjk on Mar 28, '02 03:08:39AM
Yep, less is powerful superset of more. One of its big advantages is the ability to backwards scroll/search output from a command piped to it, which is convenient for browsing multi-page output like:

ls -ARl /Applications | less

I use this tcsh alias to generalize on that idea:

alias p "!* |& $PAGER"

(insert backslash before '!' to quote it)
... after doing a "setenv PAGER less" as yobananaboy suggested. The "ls" example would then be shortened to:

p ls -ARl /Applications

Something more complicated:

p (ls -ARl /Applications | fgrep -i .html)

This is a handy alternative to scrolling the Terminal window to view output.

[ Reply to This | # ]
Re: man uses more by default
Authored by: el bid on Mar 28, '02 06:48:11AM

Yup, let's hear it for less. One of the nasties about more in the context of man is that it just "falls off the end" when you hit the end of the man page. With less you stop at the bottom (obviously) but you stay in less so that you can then use the "b" key to start paging back.

I like a nice permanent system wide fix to this, so I add

setenv PAGER less /usr/share/init/tcsh/login

el bid

[ Reply to This | # ]
Re: man uses more by default
Authored by: EphraimWoody on Mar 28, '02 09:51:18AM

Also looking for a permanent system-wide fix, I replaced /usr/bin/more with a copy of /usr/bin/less. SO far, I have not had any problems (it has been three years)

[ Reply to This | # ]
Re: man uses more by default
Authored by: sjk on Mar 28, '02 08:33:10PM

Yeah, who cares if you're the only one using your machine? Many years as a sysadmin of multi-user Unix systems has me trained to leave the "system" environment as generic as possible to help reduce novice user confusion, make upgrades easier, and other minimimal-support-staff type reasons which have varying degrees of success/failure. Pity the overly-clever wannabee who gets the "brilliant" idea of renaming /usr ... at least that's more interesting than "rm -rf /". :-) Okay, enough OT.

[ Reply to This | # ]
Re: man uses more by default
Authored by: charon on Mar 30, '02 05:14:23PM
Replacing 'more' with 'less' is a very ugly way to use 'less' as the default pager. This is a "Mac" (single user) way of dealing with such problems. Unix gives you much more flexibility for such things:
  1. The shell and other programs use variables (see man page) which allows to customize your system in a flexible, reversible way and on a "per user" basis (by setting / changing the contents of the variable). You can set a system wide default to override the program default. It's still possible for every user, to override the system default, so every user can make his/her own choice of PAGER (.i. e. the hierarchy is program default -> system default -> user setting). To set a variable permanently, you use the configuration file for your login shell (e. g. for bash: system wide: /etc/profile, per user: "~/.bash_profile, ~/.bash_login, ~/.profile, ~/.bashrc, ~/.inputrc). tcsh uses other files. Read the man page for your shell (look for keywords such as "invocation", "startup", "login", "environment", ..)
  2. On Unix systems where you don't have administrator permissions, you normally can't remove/rename programs. So changing things the "hard way" wouldn't work. Don't get dependent on solutions which are not of a general nature!
  3. Some programs change their behavior depending on the way they are called (e. g. when a program has a "compatibility mode" to a similar program or older version with another name). Instead of having to call the program with a mode option, you call it by a different name. E. g. you can invoke the bash shell by calling 'bash'. If on your system 'sh' is a link to 'bash' and you invoke 'bash' by calling 'sh', 'bash' will try to mimic the 'sh' behavior. This is an elegant mechanism of dealing with compatibility, since programs calling 'sh' don't have to be rewritten. Thus renaming Unix programs can have unexpected side effects ..
  4. If you do it the "hard way", it's better to:
    • rename 'more' to 'more.original'
    • create a symbolic link named 'more' pointing to 'less' Note: this is better than just make a copy of 'less' and name it 'more' because:
      • you don't waste space
      • the user can see, that calling 'more' is really nothing else than calling 'less' ('ls -la /usr/bin/more' tells you, that 'more' is linked to 'less')
      • you don't have to rename 'less'. Think what will happen when program A is used by program B and you rename A to something else (as you did with 'less'). B has a problem ..
      • switching to another pager is easy: just change the link to the different pager
    To revert to the original state, you simply move 'more.original' to 'more'.
Just my .02$

[ Reply to This | # ]
Re: man uses more by default
Authored by: sjk on Mar 30, '02 06:50:20PM
4. If you do it the "hard way", it's better to: - rename 'more' to 'more.original'

[ Reply to This | # ]
Re: man uses more by default
Authored by: charon on Mar 31, '02 09:31:50PM
What I do is create .DIST and .OFF directories for saving original copies of distribution files (in .DIST) and for those I've deactivated (in .OFF). Less sloppy than using filename extensions, IMHO.
Agreed. Using extensions is not a crime (Unix doesn't care for extensions) but too many '.orig', '.old', '.sav', etc. files can "litter" the filesystem. Your way is cleaner, if you have to go the "hard way".. (but avoiding the "hard way" is better). Another possible solution for saving original copies is a version control system (RCS/CVS). I started using CVS for system configuration files and shell/SQL scripts. With version control, it is possible to switch back to any previous state of a file without having to deal with the naming or placing of the old files. Furthermore, you can comment changes and group file versions belonging together, etc..

[ Reply to This | # ]
Re: man uses more by default
Authored by: sjk on Mar 28, '02 08:16:36PM
As you probably know, less has different ways of handling end-of-file behavior. I like "--quit-at-eof" ("-e"), set with the LESS envariable along with other options:

setenv LESS Mceis

Minimalist. :-)

[ Reply to This | # ]
man uses more by default
Authored by: mervTormel on Mar 28, '02 07:48:53PM

The less pager has a lot of options; they can be controlled with the environment variable LESS.


export LESS='-i -M -e -s'


setenv LESS='-i -M -e -s'

-i ignore case in searches

-M long(er) prompt than even more, like filename, lines/ofLines, %ofFile

e.g., prompt = /etc/magic lines 60-118/3837 3%

-e quit on second time at eof

-s squeeze blank lines; consecutive blank lines are squeezed into single line

See the less man pages for (many) more (pun) options (idiom)

[ Reply to This | # ]
Do a man on ed
Authored by: betabug on Mar 28, '02 05:53:29AM

Wow, you've got some things messed up. man is looking up
manual pages, ed is an editor. No relation.

[ Reply to This | # ]
Do a man on ed
Authored by: babbage on Mar 28, '02 12:52:52PM
The relation is that ed, as a low level line oriented editor, provides functionality that can be embedded in higher level tools. The most obvious tool that I know for a fact is a high-level wrapper around ed is plain old vi, but the functionality of tools like more is similar enough to ed that it's at least plausible that the "editor" is embedded in the pager. Even if it's not literally embedded, clearly the interface has been copied and much of the the behavior is identical, so thinking of them as being of the same heritage is useful -- it helps you transport keystrokes from tools you already know to tools that you're still learning about.

[ Reply to This | # ]
less is more
Authored by: osxpez on Apr 01, '02 03:18:45PM

The tip about changing your systems default pager to less is a really good one. To hint about reading the man page for less makes it even better. But I can offer a few of my favs.

<li>G (move to end of file)</li>
<li>nG (move to line n)</li>
<li>mb (set mark b [a-z])</li>
<li>'b (move to mark b)</li>
<li>ctrl-d (move half page down)</li>
<li>ctrl-u (move half page up)</li>
<li>ctrl-g (gives some file info including where you are)</li>
<li>/ (forward regexp search)</li>
<li>? (backward regexp search)</li>
<li>n (find next occurance of regexp in the same direction as last / or ?)</li>
<li>N (find next occurance of regexp in opposite direction as last / or ?)</li>
<li>q (quits)</li>

The "mark" commands works like that you first press "m" then a letter between a nd z inclusive. Let's say you press "ma". Then you can move to the "a" mark by pressing "'a".

[ Reply to This | # ]
less is more
Authored by: Willfon on Apr 05, '02 08:45:55AM
more or less...
anyways, here are some environment variables I have set that makes man use less:

LESS=-seP?f%f .?ltline %lt:byte %bb?s of %s..?e, (END)?x - Next: %x.:?pb, %pb%.. (h gives help)

But it should be noted that this will make less cat the text man'ed to the last text viewed with less; the buffer is not cleaned.


[ Reply to This | # ]