Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2019 11:15:58 -0800
From:      Aleksandr Miroslav <alexmiroslav@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   silly (non-bsd) split/cat question
Message-ID:  <CACcSE1zUtJLq5HD9S1c7cb-KUpkDpuqNEwKJd0zkabkGAXjP4w@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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?



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