5 个稳定版本
1.2.0 | 2022年11月9日 |
---|---|
1.1.1 | 2020年2月19日 |
1.0.2 | 2018年5月18日 |
1.0.0 | 2018年5月3日 |
#1844 在 命令行工具
每月 29 次下载
35KB
881 行
tabulate
使用启发式算法找到合适的列宽,以最小化浪费的空间,对齐列中的数据。适用于访问日志等文件,其中某些行的列宽度远大于其他行。
$ cat input.txt
aaa bbb ccc
a b c
aaaaaaaaaaaaaaaaaaaaaaa bb cc
aaaaa b ccccc
aaa bb ccc
aaaa bb cccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
$ tabulate <input.txt
aaa bbb ccc
a b c
aaaaaaaaaaaaaaaaaaaaaaa bb cc
aaaaa b ccccc
aaa bb ccc
aaaa bb cccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
$ tabulate -t <input.txt
aaa bbb ccc
a b c
aaaaaaa… bb cc
aaaaa b ccccc
aaa bb ccc
aaaa bb cccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
aaa bb ccc
aaa bb ccc
aaaaa b ccccc
安装
cargo install tabulate
选项
Usage: tabulate [OPTIONS]
Options:
-t, --truncate [<LIST>...]
Truncate data that does not fit in a column. Takes an optional list of columns that should be
truncated. If no LIST is given all columns are truncated
-c, --compress-cols <RATIO>
Number between 0.0 and 1.0 that controls how much columns are compressed. Set to 0 to disable
column compression, i.e. columns are sized to fit the largest value [default: 1.0]
-n, --estimate-count <N>
Estimate column sizes from the first N lines. The value 0 means all lines [default: 1000]
-i, --include <LIST>...
Select which columns to include in the output
-x, --exclude <LIST>...
Select which columns should be excluded from the output. This option takes precedence over
--include
-d, --delimiter <DELIM>
Use characters of DELIM as column delimiters [default: " \t"]
-o, --output-delimiter <DELIM>
Specify the delimiter to use to separate columns in the output [default: " "]
-s, --strict
Parse columns as strictly being delimited by a single delimiter
--online
Print lines during column size estimation phase
--column-info
Print information about the columns
-h, --help
Print help information
-V, --version
Print version information
LIST should be a comma-separated list of ranges. Each range should be of one of the following forms:
N N'th column, starting at 1
N- from N'th column to end of line
N-M from N'th to M'th column
-M from first to M'th column
依赖项
~3–13MB
~157K SLoC