LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

tuc

Enhanced text field cutting and splitting

TLDR

Cut the first field (tab-delimited)
$ echo "[a\tb\tc]" | tuc -f 1
copy
Cut fields 1 through 3
$ echo "[a:b:c:d]" | tuc -d ':' -f 1:3
copy
Reorder fields
$ echo "[a,b,c]" | tuc -d ',' -f 3,1,2
copy
Use negative indexing (last field)
$ echo "[a b c]" | tuc -d ' ' -f -1
copy
Use regex as delimiter
$ echo "[a1b2c3]" | tuc -e '[0-9]' -f 1:
copy
Replace delimiter in output
$ echo "[a:b:c]" | tuc -d ':' -r '-' -f 1:
copy
Select specific characters
$ echo "[hello]" | tuc -c 1:3
copy
Format output with template
$ echo "[a,b,c]" | tuc -d ',' --format '{1} - {2}'
copy

SYNOPSIS

tuc [flags] [options] [file]

DESCRIPTION

tuc is a modern alternative to the classic cut command, written in Rust. It provides enhanced field selection with features like negative indexing, regex delimiters, multi-character delimiters, and field reordering.Field syntax supports ranges (1:3), lists (1,3,5), negative indexes (-1 for last), and combinations. Template formatting with {1}, {2} allows custom output formatting.Unlike cut, tuc can reorder fields, use regex patterns for splitting, and handle Unicode characters correctly. The -g option treats consecutive delimiters as one, useful for whitespace-separated data with variable spacing.

PARAMETERS

-f, --fields bounds

Fields to select (default: 1:)
-b, --bytes bounds
Select specific bytes
-c, --characters bounds
Select characters (UTF-8 aware)
-l, --lines bounds
Select lines
-d, --delimiter delim
Field delimiter (default: tab)
-e, --regex pattern
Use regex as delimiter
-r, --replace-delimiter text
Replace delimiter with custom text
-t, --trim type
Trim delimiters: l (left), r (right), b (both)
-g, --greedy-delimiter
Match consecutive delimiters as one
-p, --compress-delimiter
Merge consecutive delimiters before cutting
-s, --only-delimited
Show only lines containing the delimiter
-m, --complement
Invert field selection
-j, --join
Rejoin selected parts with the delimiter
-z, --zero-terminated
Use NUL instead of newline as line terminator
--format template
Format output using field placeholders like {1}, {2}
--json
Output fields as JSON array
--no-mmap
Disable memory mapping

INSTALL

sudo apk add tuc
copy
sudo zypper install tuc
copy
brew install tuc
copy
nix profile install nixpkgs#tuc
copy

CAVEATS

Regex support increases binary size; build with --no-default-features for a smaller binary. Field numbering starts at 1, not 0. The default delimiter is tab, not whitespace.

HISTORY

tuc was created by Riccardo Attilio Galli (riquito) as a Rust-based enhancement to the traditional cut utility. The name is a playful reversal of "cut." The project was motivated by cut's limitations with regex delimiters, field reordering, and negative indexing.

SEE ALSO

cut(1), awk(1), choose(1), sed(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid