7 个版本
0.0.52 | 2021年7月15日 |
---|---|
0.0.51 | 2021年7月15日 |
0.0.48 | 2020年5月2日 |
#1093 in 文本处理
在 rcut 中使用
26KB
591 行
rcut
rcut
是一个 Rust 版本的 GNU cut
,它支持 UTF-8。
当 GNU cut
失败时,rcut
工具大放异彩
echo 🦃🐔🐓🐣🐤🐥🐦🐧🕊🦅🦆🦢🦉🦚🦜 | rcut -N -c 9,4,7,3,12,5-15
特性
- GNU cut 的直接替代品
- 默认支持 UTF-8
- 具有强大的非合并选项,可以剪切和粘贴字符范围
示例
UTF-8 模式(默认)
# Read from STDIN
rcut -c 3-6,10,12-15 < /usr/share/dict/words
# Read from files (yes you can repeat file2)
rcut -c 3-6,10,12-15 file1 file2 file2
ASCII 模式
# Read from STDIN
rcut -a -c 3-6,10,12-15 < /usr/share/dict/words
# Read from files (yes you can repeat file2)
rcut -a -c 3-6,10,12-15 file1 file2 file2
非合并选项
# You can repeat the same chars as many times as you like
echo abcdefghijklmnopqrstuvwxyz | rcut -N -c 1,3,3-7,7,1
# Character ranges will not be sorted, so compose them as you like
echo abcdefghijklmnopqrstuvwxyz | rcut --no-merge -c 9,4,7,3,12,5-15
用法
使用 rcut -h
打印用法
USAGE:
rcut [FLAGS] [OPTIONS] [files]...
FLAGS:
-a, --ascii Turn on ASCII mode (the default mode is UTF-8).
-h, --help Prints help information
-N, --no-merge
Do not sort and merge ranges.
Think of it as cut-n-paste.
Sorting and merging enabled by default.
-V, --version Prints version information
OPTIONS:
-b, --bytes <LIST>
Select only these ranges of **bytes**.
Ranges are comma-separated.
Sample ranges: 5; 3-7,9; -5; 5-; 4,8-; -4,8.
-c, --characters <LIST>
Select only these ranges of **characters**.
Ranges are comma-separated.
Sample ranges: 5; 3-7,9; -5; 5-; 4,8-; -4,8.
-d, --delimiter <delimiter>
Split lines into fields delimited by given delimiter.
Must be followed by list of fields. E.g. -f2,6-8.
-f, --fields <LIST>
Select only these ranges of **fields**.
Is dependent on the delimiter flag -d.
Ranges are comma-separated.
Sample ranges: 5; 3-7,9; -5; 5-; 4,8-; -4,8.
ARGS:
<files>...
The content of these files will be used.
If no files given, STDIN will be used.