linux 将手册页输出重定向到文件会导致单词中出现双字母

bvn4nwqk  于 2023-01-29  发布在  Linux
关注(0)|答案(3)|浏览(107)

我将man djpeg的输出重定向到一个文本文件中,以便在学习使用它时可以参考它。我的指令是man djpeg > textfile.txt。然而,输出如下所示:

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]

还有更多,但你明白了。为什么它重复一些字符?还有,如果有一些函数执行两次或缓存刷新不正确,为什么它不重复所有字符?

6qqygrtg

6qqygrtg1#

一种更简洁的方法是先将输出通过管道传输到"col-b":

man djpeg | col -b > textfile.txt

来源:https://unix.stackexchange.com/a/15866

ljo96ir5

ljo96ir52#

“man”程序最初设计用于在电传打字机上打印输出,并使用套印来产生粗体字符和下划线效果。您实际看到的是包含X^HX字符串的文件的效果,其中^H是一个退格键字符。您还可以使用_^HX这样的字符串来进行下划线(因此使用_f_i_l_e)。
使用vi之类的文本编辑器可以轻松地删除这些字符串,它将显示退格键。

:%s/_^H//g

将删除下划线,并且

:%s/.^H.//g

粗体字(上面的^H是ctrl-H。您必须使用ctrl-V ctrl-H将它们输入vi。

yjghlzjz

yjghlzjz3#

您可以简单地将STDIN重定向到任何(非)gui编辑器(支持stdin输入😜)......没有字符重复的问题
例如(我的前5名😄):

man curl | subl -
man curl | vi -
man curl | vim -
man curl | nano -
man curl | code -
...
  • P.S.**这不仅仅是man用例-任何信息都可以通过这种方式重定向 *

相关问题