将手册页输出redirect到文件结果用双字母表示

我将man djpeg的输出redirect到一个文本文件中,以便我学会使用它。 我的指令是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. 

[…待续]

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

“男人”计划最初设计用来在teletype上打印输出,并使用over-printing来产生大胆的特征和强调的效果。 你真正看到的是包含X^HX形式的字符串的文件的效果,其中^ H是一个退格字符。 你也有_^HX这样的字符串,用于加下划线(因此是_f_i_l_e)。

这些可以使用像vi这样的文本编辑器轻松删除,它将显示后面的空格。

 :%s/_^H//g 

将删除下划线,并

 :%s/.^H.//g 

(上面的^ H是ctrl-H,你必须用ctrl-V ctrl-H把它们输入到vi中。

更清洁的方法是首先将输出管道输送到“col -b”

 man djpeg | col -b > textfile.txt 

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