coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: csplit 'no-clobber' option


From: Pádraig Brady
Subject: Re: csplit 'no-clobber' option
Date: Wed, 19 Jan 2022 17:45:00 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Thunderbird/95.0

On 19/01/2022 10:36, Shehu Dikko wrote:
Currently:

% grep -c '^From ' ../mbox*
../mbox1:3
../mbox2:3

% csplit -n 1 -f "" --suppress-matched -sz ../mbox1 '/^From /' '{*}'
% ls
0 1 2
% csplit -n 1 -f "" --suppress-matched -sz ../mbox2 '/^From /' '{*}'
% ls
0 1 2

Wish:

% csplit -n 1 -f "" --suppress-matched -sz ../mbox1 '/^From /' '{*}'
% csplit -n 1 -f "" --no-clobber --suppress-matched -sz ../mbox2 '/^From /' 
'{*}'
% ls
0 1 2 3 4 5

Kindly consider a 'no-clobber' option.

That has some merit, though by default you would probably want
such a named option to fail with existing files, rather than
skip to the next available file name.
Also if you were to add such an option, it would be appropriate
to add to the split(1) command also.
If we were to implement this for either split(1) or csplit(1),
the interface might be --existing-file={overwrite,skip,fail},
with overwrite being the current default behavior.

Another option would be to have the user specify a starting number
for each invocation. We previously discussed adding a --suffix-offset
option to csplit(1) to support this:
https://lists.gnu.org/archive/html/coreutils/2020-08/msg00008.html

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]