Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting man page output to file results in double letters in words

I redirected the output of man djpeg into a text file so that I can reference it as I learn to use it. My instruction was man djpeg > textfile.txt. However, the output looks something like this:

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

NNAAMMEE
     llss -- list directory contents

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

DDEESSCCRRIIPPTTIIOONN
     For each operand that names a _f_i_l_e of a type other than directory, llss
     displays its name as well as any requested, associated information.  For
     each operand that names a _f_i_l_e of type directory, llss displays the names
     of files contained within that directory, as well as any requested, asso-
     ciated information.

     If no operands are given, the contents of the current directory are dis-
     played.  If more than one operand is given, non-directory operands are
     displayed first; directory and non-directory operands are sorted sepa-
     rately and in lexicographical order.

     The following options are available:

     --@@      Display extended attribute keys and sizes in long (--ll) output.

     --11      (The numeric digit ``one''.)  Force output to be one entry per
             line.  This is the default when output is not to a terminal.

     --AA      List all entries except for _. and _._..  Always set for the super-
             user.

     --aa      Include directory entries whose names begin with a dot (_.).

     --BB      Force printing of non-printable characters (as defined by
             ctype(3) and current locale settings) in file names as \_x_x_x,
             where _x_x_x is the numeric value of the character in octal.

     --bb      As --BB, but use C escape codes whenever possible.

[...continues]

There's more but you get the point. Why is it repeating some of the characters? Also, why doesn't it repeat all of them if there's some function executing twice or a cache flushing incorrectly?

like image 744
user2565148 Avatar asked Oct 29 '14 15:10

user2565148


1 Answers

A cleaner approach is to pipe the output to "col -b" first:

man djpeg | col -b > textfile.txt

Source: https://unix.stackexchange.com/a/15866

like image 187
David Airapetyan Avatar answered Nov 15 '22 21:11

David Airapetyan