silly (non-bsd) split/cat question

Christos Chatzaras chris at
Wed Feb 20 20:02:10 UTC 2019

> On 20 Feb 2019, at 21:15, Aleksandr Miroslav <alexmiroslav at> 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.
> But on this particular box, I only have 9GiB remaining space, so when
> bigfile is reconstituted, but before x* are deleted, I would run out
> of disk space.
> So I do something like this to reconstitute bigfile: "for i in x*; do
> cat $i >> bigfile; rm $i; done"
> That works because I delete each component file as I am recreating
> bigfile without going over the free space on my disk.
> If I want to go in the opposite direction and split bigfile into files
> of about 2GiB each, I do this: "split -b 2g bigfile; rm bigfile", but
> that uses up 12GiB of space before the rm happens.
> 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?

If you have 12GB of free RAM then mount a /tmpfs , move the file there and then run something like:

cd /home/username; cat /tmpfs/bigfile | split -b 2g

I didn't test the last command but it should work.

More information about the freebsd-questions mailing list