#utf-8 #cut #gnu #replace

app rcut

rcut 是一个支持 UTF-8 的 Rust 版本的 GNU cut

49 个版本

0.0.52 2021年7月15日
0.0.49 2021年7月15日
0.0.48 2020年5月2日
0.0.45 2020年4月18日

#8 in #cut

Download history 6/week @ 2024-03-11 6/week @ 2024-04-01

78 每月下载量

MIT/Apache

34KB
750

rcut

rcut 是 GNU cut 的 Rust 替代品,并支持 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.

依赖

~750KB