silly (non-bsd) split/cat question

Tomasz Rola rtomek at ceti.pl
Wed Feb 20 22:54:12 UTC 2019


On Wed, Feb 20, 2019 at 11:15:58AM -0800, Aleksandr Miroslav wrote:
> Suppose I have 6 files that have been created by split, they are
> roughly 2GiB each. The last one is a little smaller. In total, they
> take up about 12GiB of space.
> 
> Normally I would "cat x* > bigfile; rm x*" to get the bigfile back.
> 
[...]
> So my question is this: if I have bigfile, which is about 12GiB in
> size, and I have 9GiB left of free disk space, how do I split bigfile
> into files of about 2GiB?

copy last 2GiB of bigfile onto x_n (the exact n value, if you want to
simulate split, will be probably 6... or 5?)
truncate last 2GiB of bigfile 
n--
repeat until bigfile <2GiB
mv bigfile x_0

I have strange feeling that there is no simple cmdline pipe one-liner
to do this, instead you will have to write something custom (shell
script or better some scripting lang of your liking) and experiment
with other file until you are sure it works like it should.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.      **
** As the answer, master did "rm -rif" on the programmer's home    **
** directory. And then the C programmer became enlightened...      **
**                                                                 **
** Tomasz Rola          mailto:tomasz_rola at bigfoot.com             **


More information about the freebsd-questions mailing list