LinuxShell col
命令
Linux col命令用于过滤控制字符。
在许多UNIX说明文件里,都有RLF控制字符。当我们运用shell特殊字符">“和”>>",把说明文件的内容输出成纯文本文件时,控制字符会变成乱码,col指令则能有效滤除这些控制字符。
语法
col [-bfx] [-l<缓冲区列数>]
选项 | 描述 |
---|---|
-b | 过滤掉所有的控制字符,包括RLF和HRLF。
|
-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)