Linux将help,man,info的manual说明书手册输出文本保存为文件txt

Linux将help,man,info的manual说明书手册输出文本保存为文件txt

将 --help 保存为文本

例子
直接重定向输出

ls --help > ls--help.txt

用 col -b 滤除

find --help | col -b > find--help.txt
将 man 保存为文本

在许多UNIX说明文件里,都有RLF控制字符。当我们运用shell特殊字符">“和”>>",把说明文件的内容输出成纯文本文件时,控制字符会变成乱码,col指令则能有效滤除这些控制字符。

man find | col -b > man_find.txt
man col | col -b > man_col.txt
man man | col -b > man_man.txt
man info | col -b > man_info.txt
将 info 保存为文本

-o小写是输出为文件 , -s就是--subnodes

info man -s -o info_man.txt
        等同
info man --subnodes -o info_man.txt
        等同
info man -so info_man.txt
        对比
info man -o info_man.txt
info info -o info_info.txt --subnodes
        等同
info info -o info_info.txt -s 
        等同
info info -so info_info.txt
        对比
info info -o info_info.txt
info find --subnodes -o info_find.txt
        等同
info find -s -o info_find.txt
        等同
info find -so info_find.txt
        对比
info find -o info_find.txt

info会将一些内容按章节菜单来显示, --subnodes 是将其一起输出, 不加的话, 可能只输出总章
info的说明书里并没有提到-s选项, 但明显 -s--subnodes 效果是一样的,

'--subnodes'
	This option only has meaning when given in conjunction with
     '--output'.  It means to recursively output the nodes appearing in
     the menus of each node being output.  Menu items which resolve to
     external Info files are not output, and neither are menu items
     which are members of an index.  Each node is only output once.
col命令

Linux col命令用于过滤控制字符。

在许多UNIX说明文件里,都有RLF控制字符。当我们运用shell特殊字符">“和”>>",把说明文件的内容输出成纯文本文件时,控制字符会变成乱码,col指令则能有效滤除这些控制字符。

语法

col [-bfx] [-l<缓冲区列数>] 
选项描述
-b过滤掉所有的控制字符,包括RLF和HRLF。
  • RLF (reverse line feed)反向换行符,
  • HRLF(half-reverse line feed)半反向换行符。

  • Linux自带手册是这么说的 : 👇
    不输出任何退格符,在每列的位置上只打印最后写的那个字符.
-f滤除RLF字符,但允许将HRLF字符呈现出来。
-x以多个空格字符来表示跳格字符。
-l<缓冲区列数>预设的内存缓冲区有128列,您可以自行指定缓冲区的大小。

上面的说明来自菜鸟教程-Linux col命令

感觉和Linux系统自带的手册有些对不上, 具体有待研究

col --help
man col
info col
col --help | col -b > col--help.txt
man col | col -b > man_col.txt
info col --subnodes -o info_col.txt
col --help

Usage:
 col [options]

Filter out reverse line feeds from standard input.

Options:
 -b, --no-backspaces    do not output backspaces
 -f, --fine             permit forward half line feeds
 -p, --pass             pass unknown control sequences
 -h, --tabs             convert spaces to tabs
 -x, --spaces           convert tabs to spaces
 -l, --lines NUM        buffer at least NUM lines
 -H, --help             display this help
 -v, --version          display version


2.命令格式

col [OPTIONS]

3.选项说明

-b, --no-backspaces 不输出任何退格符,只打印写入每个列位置的最后一个字符 -f, --fine 允许正向半换行符(half-forward line feeds)。通常,处于半行分界线上的字符打印在下一行 -h, --tabs 将多个空格转换为Tab,一般 4 个 空格转为 1 个 Tab -l, --lines NUMBER 设置缓冲行为 NUMBER,默认为 128 -p, --pass 不转换未识别的控制符 -x, --spaces 将 Tab 转为多个空格,一般 1 一个 Tab 转为 4 个空格 -H, --help 显示帮助信息并退出 -V, --version 显示版本信息并退出


示例

(1)将 Tab 替换为空格,一般 1 个 Tab 转为 4 个空格。

echo -e “123 456| col -x

(2)将空格替换为 Tab,一般 4 个 空格转为 1 个 Tab。

echo -e “123 456| col -h

(3)将帮助文档内的控制符删除。以 col 命令的 manual 为例。

man col | col -b > man_col.txt

来自Ubuntu22.04Server版

COL(1)							    User Commands						       COL(1)

NAME
       col - filter reverse line feeds from input

SYNOPSIS
       col options

DESCRIPTION
       col filters out reverse (and half-reverse) line feeds so the output is in the correct order, with only forward and
       half-forward line feeds. It also replaces any whitespace characters with tabs where possible. This can be useful in processing the output of nroff(1) and tbl(1).
       
       col 过滤掉反向(和半反向)换行,使输出按正确的顺序排列,只有正向和
       半正向换行。它还会在可能的情况下用制表符替换任何空格字符。这在处理
       nroff(1) 和 tbl(1) 的输出时很有用。 (nroff和tbl是两个命令)

       col reads from standard input and writes to standard output.
       col 从标准输入读取并写入标准输出。

OPTIONS
       -b, --no-backspaces
	   Do not output any backspaces, printing only the last character written to each column position.
	   不输出任何退格,仅打印最后一个字符写入每个列位。

       -f, --fine
	   Permit half-forward line feeds. Normally characters destined for a half-line boundary are printed on the following line.

       -h, --tabs
	   Output tabs instead of multiple spaces.

       -l, --lines number
	   Buffer at least number lines in memory. By default, 128 lines are buffered.

       -p, --pass
	   Force unknown control sequences to be passed through unchanged. Normally col will filter out any control sequences other
	   than those recognized and interpreted by itself, which are listed below.

       -x, --spaces
	   Output multiple spaces instead of tabs.

       -V, --version
	   Display version information and exit.

       -H, --help
	   Display help text and exit.

CONFORMING TO
       The col utility conforms to the Single UNIX Specification, Version 2. The -l option is an extension to the standard.

NOTES
       The control sequences for carriage motion that col understands and their decimal values are listed in the following table:

       ESC-7
	   reverse line feed (escape then 7)

       ESC-8
	   half reverse line feed (escape then 8)

       ESC-9
	   half forward line feed (escape then 9)

       backspace
	   moves back one column (8); ignored in the first column

       newline
	   forward line feed (10); also does carriage return

       carriage return
	   (13)

       shift in
	   shift to normal character set (15)

       shift out
	   shift to alternate character set (14)

       space
	   moves forward one column (32)

       tab
	   moves forward to next tab stop (9)

       vertical tab
	   reverse line feed (11)

       All unrecognized control characters and escape sequences are discarded.

       col keeps track of the character set as characters are read and makes sure the character set is correct when they are output.

       If the input attempts to back up to the last flushed line, col will display a warning message.

HISTORY
       A col command appeared in Version 6 AT&T UNIX.

SEE ALSO
       expand(1), nroff(1), tbl(1)

REPORTING BUGS
       For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.

AVAILABILITY
       The col command is part of the util-linux package which can be downloaded from Linux Kernel Archive
       <https://www.kernel.org/pub/linux/utils/util-linux/>.

util-linux 2.37.2					      2021-06-02						       COL(1)

来自Fedora36Server版

col(1)                                                                                   General Commands Manual                                                                                  col(1)

NAME(名称)
       col - 过滤掉输入中的反向换行符

SYNOPSIS(总览)
       col [ -bfx ] [ -l num ]

DESCRIPTION(描述)
       col 过滤掉反向(以及半反向)换行符(LF: line feed or NL: new line), 这样输出按正常顺序,即只包括正向和半正向换行符, 而且在可能的地方使用tab替换白空格.这对 nroff(1) 和 tbl(1) 的输出处理很有用处.

       col 从标准输出读入,并写出到标准输出上.

       选项如下:

       -b     不输出任何退格符,在每列的位置上只打印最后写的那个字符.

       -f     允许正向半换行符(``fine''模式).  通常,处于半行分界线上的字符打印在下一行.

       -x     输出多个空格以替换tab.

       -l num 在内存中至少缓冲 num 行.  默认情况下,缓冲128行.

       col 所能理解的用于回车操作的控制序列以及它们的十进制值都列在下面的表中:

       ESC-7  反向换行符(escape后接7)

       ESC-8  反向半换行符(escape后接8)

       ESC-9  正向半换行符(escape后接9)

       backspace
              反向移动一列(8);在第一列则忽略.

       carriage return
              (13)

       newline
              正向换行符(10);同时执行回车(carriage return)操作

       shift in
              转到正常字符集(15)

       shift out
              转到备选的字符集(14)

       space  正向移动一列(32)

       tab    正向移动到下一个tab(9)

       vertical tab
              反向换行符(11)

       丢弃所有不被承认的控制字符和escape序列.

       当读取字符时, col 保持着与字符集的联系,而且在输出时确保字符集是正确的.

       如果输入设备试图回复到最近被刷新的行, col 会显示一条警告消息.

SEE ALSO(另见)
       expand(1) nroff(1) tbl(1)

HISTORY(历史)
       col 命令出现于AT&T UNIX版本6.

[中文版维护人]
       riser <boomer@ccidnet.com>

[中文版最新更新]
       2000/12/6

《中国Linux论坛man手册页翻译计划》:
       http://cmpp.linuxforum.net

跋
       本页面中文版由中文 man 手册页计划提供。
       中文 man 手册页计划:https://github.com/man-pages-zh/manpages-zh

COL 1                                                                                         1991年6月17日                                                                                       col(1)
COL(1)                                                                                        User Commands                                                                                       COL(1)

NAME
       col - filter reverse line feeds from input

SYNOPSIS
       col options

DESCRIPTION
       col filters out reverse (and half-reverse) line feeds so the output is in the correct order, with only forward and half-forward line feeds. It also replaces any whitespace characters with tabs
       where possible. This can be useful in processing the output of nroff(1) and tbl(1).

       col reads from standard input and writes to standard output.

OPTIONS
       -b, --no-backspaces
           Do not output any backspaces, printing only the last character written to each column position.

       -f, --fine
           Permit half-forward line feeds. Normally characters destined for a half-line boundary are printed on the following line.

       -h, --tabs
           Output tabs instead of multiple spaces.

       -l, --lines number
           Buffer at least number lines in memory. By default, 128 lines are buffered.

       -p, --pass
           Force unknown control sequences to be passed through unchanged. Normally col will filter out any control sequences other than those recognized and interpreted by itself, which are listed
           below.

       -x, --spaces
           Output multiple spaces instead of tabs.

       -V, --version
           Display version information and exit.

       -H, --help
           Display help text and exit.

CONFORMING TO
       The col utility conforms to the Single UNIX Specification, Version 2. The -l option is an extension to the standard.

NOTES
       The control sequences for carriage motion that col understands and their decimal values are listed in the following table:

       ESC-7
           reverse line feed (escape then 7)

       ESC-8
           half reverse line feed (escape then 8)

       ESC-9
           half forward line feed (escape then 9)

       backspace
           moves back one column (8); ignored in the first column

       newline
           forward line feed (10); also does carriage return

       carriage return
           (13)

       shift in
           shift to normal character set (15)

       shift out
           shift to alternate character set (14)

       space
           moves forward one column (32)

       tab
           moves forward to next tab stop (9)

       vertical tab
           reverse line feed (11)

       All unrecognized control characters and escape sequences are discarded.

       col keeps track of the character set as characters are read and makes sure the character set is correct when they are output.

       If the input attempts to back up to the last flushed line, col will display a warning message.

HISTORY
       A col command appeared in Version 6 AT&T UNIX.

SEE ALSO
       expand(1), nroff(1), tbl(1)

REPORTING BUGS
       For bug reports, use the issue tracker at https://github.com/util-linux/util-linux/issues.

AVAILABILITY
       The col command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.

util-linux 2.38-rc1                                                                            2022-01-06                                                                                         COL(1)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kfepiza

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值