On 11/07/2023 15:29, Tommy Bollman wrote:
Hello guys.
Feature request.
I have made a little command line cp utility *nrcp*, that basically takes
a file name as an argument and appends an ascending number at the end of it.
The intention is to be able to keep backups for back tracking during
experimenting with files.
I honed the idea further, and I added a **-k** switch, that preserves the
file mode, so that I can just "nrcp -k shellscript" which returns a
shellscript.0 that is still executable, but I can edit it at my hearts
contents, without ruining the real one.
While at that feature, I figured I could also embed the number, which is
much more practical if I work on a c-file, or any other file-type where the
extension matters. And I implemented that in the -k switch, so it both
preserves file mode, and embeds the number inside any extension.
Honestly, I'd rather see the utility in the **moreutils** packaged, but it
is without maintainer at the moment. And I am being nagged for not trying
to get you to implement this into core-utils, as it IS a SUPER-PRACTICAL
feature. :)
I see that cp doesn't do anything with the **-k** nor **-K** switches, so I
humbly propose those for invoking the behavior in cp.
The whole discussion has been in this reddit thread:
<
https://www.reddit.com/r/commandline/comments/14vptm6/a_little_tool_that_creates_a_numbered_copy_of_a/
The code for the utility resides in this gist:
<https://gist.github.com/McUsr/74e277ff8bd4707f151cf73eae8e20c4>
I hope to hear from you, whether the message be positive or negative!
And I am happy for GNU existing!
Keep up the good work and have a wonderful rest of the summer!
I've not looked at your util, but it sound similar to the
--backup=numbered functionality already in GNU cp.
For example if you wanted to create a backup of file.c you could:
cp --force --backup=numbered file.c{,}
cheers,
Pádraig