4

Say if I run the command man who, I have to keep pressing space or enter to show all content. Is there a way to show all of the content at once?

1
8

Pipe the output through cat:

man who | cat

This works because man (or actually pager, which is a symlink to less) will check to see what kind of terminal is connected to STDOUT. If there is no terminal, i.e if STDOUT is redirected to a file or pipe, then there will be no attempt to format the text so that it can be interactively scrolled.

3
  • That's nice too, and the first thing I tried... but I couldn't find documentation guaranteeing that it would work. But as man man mentions, the default pager is pager -s, which is another name for less, and it is Well-Known that piping from less works just as one would expect. So this should be safe. – dhag Mar 10 '15 at 22:20
  • That's probably the most portable, followed by PAGER=cat man who. @dhag Note that man-db (the most common man implementation on Linux nowadays) at least does not spawn less when stdout is not a terminal. And pager does not have to be less (neither pager or less exist on some systems). – Stéphane Chazelas Mar 10 '15 at 23:01
  • 2
    +1, DNUUOC (Definitely Not Useless Use Of Cat) – Olivier Dulac Mar 11 '15 at 10:16
5

Use cat as the pager; for example this will dump the entire manpage for command ls:

man -P cat ls

Note that this isn't portable (I only tried this on Debian and Mac OS systems); for example, on Ultrix or Tru64, -P sets the manpath.

5
  • This is better than my answer because it takes out an unnecessary spawn of less – Digital Trauma Mar 10 '15 at 22:17
  • Good point, though it could be argued that your answer is better because it saves one from having to know about -P. – dhag Mar 10 '15 at 22:22
  • 1
    Not all man implementations have a -P. Or it may mean something else (like specifying a manpath on Ultrix). – Stéphane Chazelas Mar 10 '15 at 23:04
  • You learn something everyday! Thanks @StéphaneChazelas, I added your comment to the answer. – dhag Mar 11 '15 at 14:02
  • Yes, I don't think it's portable outside Linux (the two commonly found man implementations there derive from a common one that supports it) and FreeBSD and their derivatives (even other BSDs like NetBSD/OpenBSD don't support it). – Stéphane Chazelas Mar 11 '15 at 14:50
3

One age-old stunt:

man whatever | col -b > whatever.txt

Using the very obscure col command filters out all the weird backspaces and duplicate characters that nroff uses to do formatting. Then, you can use your choice of text editor to look over the entire man page.

1

If you use a terminal emulator that supports scrolling back, and have set the size of the scrollback buffer to something "sufficently large", you can use that scrollback for navigating the output.

I would use

MANPAGER=cat man who

to write out all the man page text at once to the terminal (it's a variant of man -P cat ls).

I use konsole as terminal, which is set up to support scrolling using the mouse scroll wheel.
It works very well for this case - the wheel scrolls through the man page text, and entering any character jumps back to the prompt. Using the keys Shift+PgUp and Shift+PgDn, you can scroll by terminal hight sections.

Other terminal emulators can be set up in a similar way.
As alternative, a terminal multiplexer like tmux/screen can be used to provide the scrollback buffer.

If you can not scroll up to the top of the man page, set the scrollback buffer size of your terminal emulator to a larger value.

0

Suppose you need to read manul ls :

man ls | sed  's/\n//g'
3
  • What do you think this accomplishes? By itself, sed 's/\n//g' is a pass-through; you might as well be saying man whatever | cat, which was already given. – G-Man Says 'Reinstate Monica' Mar 11 '15 at 0:35
  • 2
    You could use man ls | tr -d '\n' to do what that seems to intend, but that does not help with the question (and is not that useful in the first place). – Volker Siegel Mar 11 '15 at 0:41
  • Strictly speaking, this does achieve what the OP wants. Yes, it is needlessly complicated, yes it's the same as doing a non-action like sed 's/./&/', but it does result in the whole man page being printed. – terdon Mar 11 '15 at 12:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.