Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2019 23:46:45 +0100
From:      Tomasz Rola <rtomek@ceti.pl>
To:        freebsd-questions@freebsd.org
Subject:   Re: silly (non-bsd) split/cat question
Message-ID:  <20190220224645.GA13862@tau1.ceti.pl>
In-Reply-To: <CACcSE1zUtJLq5HD9S1c7cb-KUpkDpuqNEwKJd0zkabkGAXjP4w@mail.gmail.com>
References:  <CACcSE1zUtJLq5HD9S1c7cb-KUpkDpuqNEwKJd0zkabkGAXjP4w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@bigfoot.com             **



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190220224645.GA13862>