gpt4 book ai didi

formatting - 如何在将手册页转储到文本文件时保留格式

转载 作者:行者123 更新时间:2023-12-03 17:52:08 25 4
gpt4 key购买 nike

看起来这应该是一个非常简单的问题,但我无法弄清楚(显然)。

例如,当我打开终端窗口并运行命令 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.

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

最佳答案

man 输出有很多隐藏的退格字符。您看到的所有额外的 SBS 字符都是特殊字符。以下命令将清除这些:

man ffmpeg | col -b > man_ffmpeg.txt

现在您可以获得非常清晰的纯文本输出。

来源:

man man

...

To get a plain text version of a man page, without backspaces and underscores, try

# man foo | col -b > foo.mantxt

编辑:小的澄清

关于formatting - 如何在将手册页转储到文本文件时保留格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17034503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com