如何在将man手册转储到文本文件时保留格式。

3
似乎这应该是一个相当简单的问题,但我无法想出解决方法(显然)。
当我打开一个终端窗口并运行例如man ffmpeg命令时,我在终端中看到的输出如下:
FFMPEG(1)                                                            FFMPEG(1)

NAME
       ffmpeg - ffmpeg video converter

SYNOPSIS
       ffmpeg [global_options] {[input_file_options] -i input_file} ...
       {[output_file_options] output_file} ...

DESCRIPTION
       ffmpeg is a very fast video and audio converter that can also grab from
       a live audio/video source. It can also convert between arbitrary sample
       rates and resize video on the fly with a high quality polyphase filter.

...这是我期望的样子。然而,当我尝试使用命令man ffmpeg > man_ffmpeg.txt将这些信息转储到文本文件中时,我得到的结果看起来像这样:

FFMPEG(1)                                                            FFMPEG(1)



NNAAMMEE
       ffmpeg - ffmpeg video converter

SSYYNNOOPPSSIISS
       ffmpeg [_g_l_o_b_a_l___o_p_t_i_o_n_s] {[_i_n_p_u_t___f_i_l_e___o_p_t_i_o_n_s] -i _i_n_p_u_t___f_i_l_e} ...
       {[_o_u_t_p_u_t___f_i_l_e___o_p_t_i_o_n_s] _o_u_t_p_u_t___f_i_l_e} ...

DDEESSCCRRIIPPTTIIOONN
       ffmpeg is a very fast video and audio converter that can also grab from
       a live audio/video source. It can also convert between arbitrary sample
       rates and resize video on the fly with a high quality polyphase filter.

我想做的就是将我通常在终端中看到的内容转储到文本文件中,但显然我做错了什么。最好的方法是什么?

1个回答

5

man 命令的输出中包含许多隐藏的退格字符。你看到的所有额外的 SBS 字符都是特殊字符。下面的命令将清除这些字符:

man ffmpeg | col -b > man_ffmpeg.txt

现在,你可以获得清晰明了的纯文本输出。

来源:

man man

...

要获取一个 man 页面的纯文本版本,不包括退格和下划线,请尝试

# man foo | col -b > foo.mantxt

编辑:稍作澄清


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接