tuc-0.7.0 is not a library.
Visit the last successful build:
tuc-1.2.0
tuc (when cut doesn't cut it)
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.
Install
Download one of the prebuilt binaries
or run
cargo install tuc
Help
tuc 0.8.0 [UNRELEASED]
When cut doesn't cut it.
USAGE:
tuc [FLAGS] [OPTIONS]
FLAGS:
-p, --compress-delimiter Collapse any sequence of delimiters
-s, --only-delimited Do not print lines not containing delimiters
-V, --version Prints version information
-z, --zero-terminated line delimiter is NUL (\0), not LF (\n)
-h, --help Prints this help and exit
-m, --complement keep the opposite fields than the one selected
-j, --join write the delimiter between fields
OPTIONS:
-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)
-l, --lines <fields> Same as --fields, but it keeps lines 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
Notes:
--trim and --compress-delimiter are applied before --fields
--lines does not load the whole input in memory if the fields are ordered
and non-negative (e.g. -l 1,3:4,4,7) and options -p/-m have not been set
Examples
# Cut using a greedy delimiter
|
# Compress delimiters after cut
|
# Replace remaining delimiters with something else
|
# Indexes can be negative and rearranged
|
# Delimiters can be any number of characters long
|
# Can split on unicode scalar values (it expects UTF-8 encoding)
|
# Can split on characters
|
# Can split on bytes (the following emoji are 4 bytes each)
|
# Can keep the opposite fields
|
LICENSE
Tuc is distributed under the GNU GPL license (version 3 or any later version).
See LICENSE file for details.