从man的输出保存的文件中不需要的ctrl + h

提姆

之后man less(并有选择地点击h“更少的命令摘要”),由于man用于less显示文本,因此我点击s了将文本保存到文件中。

当我在emacs或vi中打开文件时,出现不必要的ctrl + h,并且某些字符重复出现是不希望的。这是为什么?如何正确保存“更少的命令摘要”?

为什么将输出重定向man less到文件没有问题?

谢谢。

在此处输入图片说明

斯蒂芬·查泽拉斯(Stephane Chazelas)

这可以追溯到70年代的远程打字机(ttys!)。

Sending X<backspace>X (^H being the ASCII BS character) to a tele-typewriter, causes it to write X, go back one character and write X again on top of itself. It being written twice makes it appear as bold.

Similarly, for underline, you'd write _<backspace>X which would write X on top of an underscore .

roff, the typesetting system used by man was one of the first thing written for Unix in the 70s as that's how the Unix authors got their funding.

Using man then on a tele-typewriter would send those sequences to write bold and underline.

Tele-typewriters soon got replaced with Cathod-Ray-Tube terminals. There, the BS character just moves the cursor backward and characters override the character underneath.

So sending X<backspace>X or _<backspace>X there just displays X. CRTs also have a limited screen space (as opposed to paper in tele-typewriters), so pagers like more were born.

Pagers were enhanced to understand those X<BS>X sequences and use corresponding escape sequences to tell the terminal to display bold or underline.

Nowadays pagers, including more, less, most, w3m still understand those sequences.

And man still uses them to display bold or underline when the output goes to a pager.

When man (at least some implementations) detects that the output doesn't go to a terminal, it doesn't invoke a pager and does not use those sequences, which is why you don't see them when you redirect to a file.

如果要删除这些序列,可以使用col -b命令。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章