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

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

本文介绍了将手册页输出重定向到文件会导致单词中出现双字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 man djpeg 的输出重定向到一个文本文件,以便在学习使用它时可以引用它.我的指令是 man djpeg>textfile.txt .但是,输出看起来像这样:

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?

推荐答案

'man'程序最初旨在在电传打字机上打印其输出,并使用套印来产生粗体和强调效果.您实际上看到的是文件包含格式为 X ^ HX 的字符串的效果,其中^ H是退格字符.您还可以使用诸如 _ ^ HX 之类的字符串作为下划线(因此_f_i_l_e).

The 'man' program was originally designed to print its output on teletypes, and uses over-printing to produce bold character and underlining effects. What you're actually seeing is the effect of the file containing strings of the form X^HX, where the ^H is a backspace character. You also have strings like _^HX, for underlining (hence the _f_i_l_e).

可以使用文本编辑器(如 vi )轻松剥离这些文本,该文本编辑器将显示退格键.

These can be stripped easily using a text editor like vi, which will display the backspaces.

:%s/_^H//g

将删除下划线,并且

:%s/.^H.//g

黑体字(上面的^ H是ctrl-H.您必须使用 ctrl-V ctrl-H 将其输入到vi中.

the boldings (the ^H in the above is ctrl-H. You will have to use ctrl-V ctrl-H to enter these into vi.

这篇关于将手册页输出重定向到文件会导致单词中出现双字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 10:56