HomeFreeBSD

split(1): auto-extend suffix length if required

Description

split(1): auto-extend suffix length if required

If the input cannot be split into the number of files resulting from the
default suffix length, automatically extend the suffix length rather
than bailing out with 'too many files'.

Suffixes are extended such that the resulting files continue to sort
lexically and "cat *" would reproduce the input. For example, splitting
a 1M lines file into (default) 1000 lines per file would yield files
named 'xaa', 'xab', ..., 'xyy', 'xyz', 'xzaaa', 'xzaab', ..., 'xzanl'.

If '-a' is specified, the suffix length is not auto-extended.

This behavior matches GNU sort(1) since around version 8.16.

Reviewed by: christos
Approved by: kevans
Different Revision: https://reviews.freebsd.org/D38279

(cherry picked from commit c4f7198f47c15eece849d06e8fdd1fb46ed43bba)

split(1): add '-c' to continue creating files

Currently, split(1) will clobber any existing output files:

$ split file; ls
xaa xab xac xad
$ split second-file; ls
xaa xab xac xad xae xaf

This patch adds a flag "-c" (mnemonic "create, don't overwrite" or
"continue where you left off"):

$ split file; ls
xaa xab xac xad
$ split -c second-file; ls
xaa xab xac xad xae xaf xag xah xai xaj

Reviewed by: christos
Approved by: kevans
Different Revision: https://reviews.freebsd.org/D38553

(cherry picked from commit ac17fc816e67a4e5e2e481b5001577a8d589f8b6)

Details

Provenance
jschauma_netmeister.orgAuthored on May 30 2023, 12:55 PM
desCommitted on Sep 14 2023, 2:59 PM
Parents
rGa721afaf8543: split: Update synopsis and usage; fix examples
Branches
Unknown
Tags
Unknown