When I execute man ls > temp.txt the output text file is corrupted. By corrupted I mean that first and last letters in some words are overly repeated.

Several first lines in temp.txt:

LS(1)                     BSD General Commands Manual                    LS(1)

     llss -- list directory contents

     llss [--AABBCCFFGGHHLLOOPPRRSSTTUUWW@@aabbccddeeffgghhiikkllmmnnooppqqrrssttuuwwxx11] [_f_i_l_e _._._.]


And so on. Without redirection man ls is perfectly normal. What's happening?

  • Interestingly, viewing the file using less or more displays the formatting correctly. If you use vim, it'll show the raw backspaces (^H) with the extra letters.
    – Kelvin
    Commented Jul 21, 2015 at 17:54
  • 2
    Your files suffer from hiccups.
    – Cthulhu
    Commented Jul 22, 2015 at 12:28
  • Interesting, the man command on my Linux computer doesn't behave like this when the output is redirected. Commented Jul 23, 2015 at 8:39

5 Answers 5


From man man:

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

    # man foo | col -b > foo.mantxt

man prints formatted version of man page, underscores and double letters are parsed

Its not so much that they are 'parsed' but rather "if you don't have a terminal, bold format is to be displayed as a repeated character". Once you hook it up to a terminal (vt100, xterm, Terminal, etc...), man recognizes the terminal and sends the appropriate control codes to do color, bold, underline and the like. Its being parsed correctly - just for a null terminal type.

comment by MichaelT


Once upon a time, computers were routinely hooked up to teletypes (teleprinters) which would print all text on paper in real time as it was received. Although teleprinters didn't have any facilities for underlined or bold-faced text, outputting an underline, backspacing, and printing something else would cause that something else to appear underlined. Likewise outputting a character, backspacing, and outputting the same character would tend to make the character appear darker, though the effectiveness of that would vary depending upon the quality of the installed ribbon (if the ribbon was old and feeble, typing the same character twice would make it significantly darker; with a new ribbon typing the character even once would achieve close to maximum blackness). Further, even if a user wasn't attached to a printer, redirecting the output of man to a print spooler would have been pretty common, which probably explains why man would behave that way even when the output was redirected.

BTW, on some printers (and even teleprinters), the performance of _←U_←N_←D_←E_←R_←L_←I_←N_←I_←N_←G would be noticeably worse than ___________←←←←←←←←←←←UNDERLINING, since the former requires the printhead to repeatedly reverse direction (and typically overshoot its target at both ends). The same would be true when using multi-strike boldface as well, but there the behavior could actually be advantageous since the first time each character is printed would immediately follow a backspace character and the second would not. If the print head was accelerating while printing the first character, that would cause it to be misaligned slightly relative to the second, making the bold-face effect more effective.

  • The more I learn about Unix, the more I find how it is encumbered with backwards compatibility, just like Windows.
    – Siyuan Ren
    Commented Jul 22, 2015 at 4:49
  • Neat history lesson! Great to see why certain methods might be preferred over others. Commented Jul 22, 2015 at 21:41

Mateusz's answer is correct, but it is worth pointing out that rather than stripping out formatting intended for a tty, you can have man format differently.

For example, you can get a nicely formatted pdf instead with:

man -t ls | pstopdf -i -o ~/ls.pdf
  • I have been using OnyX for years now mainly to get my man pages printed as this does. No more! I'll write this into a script that will do all the man pages on my system. Thanks so much for this as I gave up looking long ago any why I been using OnyX. I much prefer doing things like this from a Terminal and now I can. Commented Jul 21, 2015 at 17:25
  • Nice feature. Is there a simple way to output html besides this? gzip -dc $(man -w ls) | groff -Thtml -mandoc -c > /tmp/man-ls.html
    – Kelvin
    Commented Jul 21, 2015 at 18:12
  • The manpage for man says that -t formats with groff -Tps ... and from running strings on /usr/bin/man, that appears to be hardcoded. And since -Tps overrides GROFF_TYPESETTER, your solution might be the most viable. Though you are missing a step in your pipeline. You want tbl then groff. Try man -d ls to see the pipeline it uses.
    – Tim B
    Commented Jul 21, 2015 at 18:28

As an alternative, I have the following shell function defined (called from Oh-my-ZSH's OS X plugin):

man-preview () {
    man -t "$@" | open -f -a /Applications/Preview.app

This results in the desired man page being opened in Preview with all the pretty formatting one could desire. It's easy enough to add this single alias to your ~/.profile (I think pman is easier than man-preview, so I've set alias pman='man-preview in my ~/.zshrc).

P.S. I've seen the pman function defined in various dot files around the internet, Oh-my-ZSH just happens to be where mine is defined.


Or you can use ManOpen by Carl Lindberg to lookup and print any man page. ManOpen was first developed for NeXtStep and still works thanks to Carl.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .