28

By default, man uses less to output text. How can I tell it to just output to stdout? My terminal emulator has a scroll bar and search function and I want to use those instead of the arrow keys.

0

4 Answers 4

36

Actually it uses whatever is specified in the MANPAGER or the PAGER environment variable.

Depending on your man implementation and version there could be also a command line switch to specify the pager.

With the man-db implementation I use all the below ways work:

MANPAGER=cat man man

PAGER=cat man man

MANOPT='-P cat' man man

man -P cat man

To set it permanently, just add it to your ~/.bashrc (or other initialization file used by your shell):

export MANPAGER=cat

That works with some older man implementations too, while MANOPT is man-db specific:

export MANOPT='-P cat'

(Better do not set PAGER that way. That one is used by many other applications too.)

There could be also a global configuration file. man-db has /etc/man_db.conf or /etc/manpath.config. There you can set:

DEFINE    pager    cat

But unfortunately that is taken in consideration only if neither MANPAGER nor PAGER is set.

4
  • 2
    Good answer. Re: ~/.bashrc, You could also wrap the export in a conditional so it only sets the pager if it's the appropriate terminal/emulator: if [ "x$TERM" = "xxterm" ]; then export MANPAGER=cat; fi; obviously replace xterm with the appropriate emulator.
    – Kevin
    Oct 27, 2011 at 14:23
  • 1
    Actually, it's good and by design that manpath.config is taken into account later. Both PAGER and MANPAGER are user level, where the config file is system level. If system level would take precedence then users could not override at all. Oct 29, 2011 at 17:29
  • @PauldeVrieze, you are right on MANPAGER. I used the “unfortunately” word for the fact that the behavior also applies to PAGER, which is a generic setting (used by many tools) and I would prefer it to not override a specific setting (used by only one tool), even if that one is system level.
    – manatwork
    Oct 30, 2011 at 11:22
  • If you want to override a specific setting for a single tool you can always do so by creating an alias, a shell function or a wrapper script. Either of those would amount to: PAGER=cat man, for example: alias man='PAGER=cat MANPAGER=cat man' Nov 1, 2011 at 11:32
8

Simply pipe the output of man to cat?

man ls | cat   # useful use of cat
3
  • 7
    Note that depending on the man implementation, that either 1) rises error, 2) displays troff format codes in the terminal, 3) removes all formatting, 4) works as expected.
    – manatwork
    Oct 27, 2011 at 12:59
  • 3
    I've never seen it do other than 4. Oct 30, 2011 at 1:54
  • @KeithThompson macOS's man seems to use the pager set in MANPAGER even when the output is a file or a pipe. And if the pager is less, then it's all good because less behaves like cat when output is a pipe... But if you use something else (like Vim, which I use), then it's not so good.
    – muru
    Oct 6, 2017 at 5:05
3

Try these commands to generate man output without a pager.

  • man ls | cat (generated fixed width)

  • man -P cat ls (generated variable width)

I was on a GNU linux system

1

Another angle: Similar to Tony's answer.

You can also redirect man output into a file and view it with your favorite text editor or even add bookmarks, comments, etc. to it.

man bash  > bashman.txt

I have a copy of the bash man page as well as just the sections on bash flow control and bash test flags saved as text files in my bin directory so I can load them right into my text editor (kate) for reference while I'm writing bash scripts.


Warning: depending on your system and the man page, the above command may result in formatting information and control characters in the file.

To avoid this, do as suggested in LESS='+/^TIPS' man man:

To  get a  plain  text  version  of a man page, without backspaces and
underscores, try

  # man foo | col -b > foo.mantxt
1
  • 1
    @Wildcard - Thanks. I didn't know about that.
    – Joe
    Oct 7, 2017 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy