tuc 0.6.0

When cut doesn't cut it
tuc-0.6.0 is not a library.

tuc (when cut doesn't cut it)

version ci license

We've all been there. You want to cut some string on a delimiter repeated in a non-deterministic way. Maybe you even want to use negative indexes or replace the delimiters in the cut part with something else... That's where tuc can help.


Download one of the prebuilt binaries

or run

cargo install tuc


tuc 0.6.0
When cut doesn't cut it.

    tuc [FLAGS] [OPTIONS]

    -p, --compress-delimiter      Collapse any sequence of delimiters
    -s, --only-delimited          Do not print lines not containing delimiters
    -V, --version                 Prints version information
    -h, --help                    Prints this help and exit

    -b, --bytes <fields>          Same as --fields, but it cuts on bytes instead
                                  (doesn't require a delimiter)
    -d, --delimiter <delimiter>   Delimiter to use to cut the text into pieces
                                  [default: \\t]
    -f, --fields <fields>         Fields to keep, 1-indexed, comma separated.
                                  Use colon for inclusive ranges.
                                  e.g. 1:3 or 3,2 or 1: or 3,1:2 or -3 or -3:-2
                                  [default 1:]
    -c, --characters <fields>     Same as --fields, but it keeps characters instead
                                  (doesn't require a delimiter)
    -r, --replace-delimiter <s>   Replace the delimiter with the provided text
    -t, --trim <trim>             Trim the delimiter. Valid trim values are
                                  (l|L)eft, (r|R)ight, (b|B)oth


# Cut using a greedy delimiter
❯ echo "foo    bar   baz" | tuc -d ' ' -f 2:
bar   baz
# Compress delimiters after cut
❯ echo "foo    bar   baz" | tuc -d ' ' -f 2: -p
bar baz
# Replace remaining delimiters with something else
❯ echo "foo    bar   baz" | tuc -d ' ' -f 2: -p -r ' -> '
bar -> baz
# Indexes can be negative and rearranged
❯ echo "a b c" | tuc -d ' ' -f -1,-2,-3
# Delimiters can be any number of characters long
❯ echo "a<sep>b<sep>c" | tuc -d '<sep>' -f 1,3
# Can split on unicode scalar values (it expects UTF-8 encoding)
❯ echo "a𝌆b𝌆c" | tuc -d '𝌆' -f 1,3
# Can split on characters
❯ echo "😁🤩😝😎" | tuc -c 4,3,2,1
# Can split on bytes (the following emoji are 4 bytes each)
❯ echo "😁🤩😝😎" | ./target/debug/tuc -b 5:8


Tuc is distributed under the GNU GPL license (version 3 or any later version).

See LICENSE file for details.