From owner-freebsd-questions@freebsd.org Wed Feb 20 20:02:10 2019 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A02B14D9E13 for ; Wed, 20 Feb 2019 20:02:10 +0000 (UTC) (envelope-from chris@cretaforce.gr) Received: from smtp2.cretaforce.gr (smtp2.cretaforce.gr [159.69.244.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.cretaforce.gr", Issuer "RapidSSL RSA CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470AE6AE60 for ; Wed, 20 Feb 2019 20:02:09 +0000 (UTC) (envelope-from chris@cretaforce.gr) Received: from server1.cretaforce.gr (server1.cretaforce.gr [138.201.248.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.cretaforce.gr", Issuer "RapidSSL RSA CA 2018" (verified OK)) by smtp2.cretaforce.gr (Postfix) with ESMTPS id 251621FA28 for ; Wed, 20 Feb 2019 22:02:07 +0200 (EET) Received: from [192.168.2.6] (athedsl-127389.home.otenet.gr [85.75.73.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: chris@cretaforce.gr) by server1.cretaforce.gr (Postfix) with ESMTPSA id E47AE2732E for ; Wed, 20 Feb 2019 22:02:06 +0200 (EET) From: Christos Chatzaras Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: silly (non-bsd) split/cat question Date: Wed, 20 Feb 2019 22:02:05 +0200 References: To: FreeBSD Questions In-Reply-To: Message-Id: <3F118B74-5B28-484E-A4E0-034E7C0E410A@cretaforce.gr> X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 470AE6AE60 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of chris@cretaforce.gr designates 159.69.244.42 as permitted sender) smtp.mailfrom=chris@cretaforce.gr X-Spamd-Result: default: False [-3.12 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:159.69.244.42]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[cretaforce.gr]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-0.69)[ipnet: 159.69.0.0/16(-1.20), asn: 24940(-2.22), country: DE(-0.01)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mail.cretaforce.gr]; NEURAL_HAM_SHORT(-0.53)[-0.527,0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[42.244.69.159.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:159.69.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 20:02:10 -0000 > On 20 Feb 2019, at 21:15, Aleksandr Miroslav = wrote: >=20 > 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. >=20 > Normally I would "cat x* > bigfile; rm x*" to get the bigfile back. >=20 > 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. >=20 > So I do something like this to reconstitute bigfile: "for i in x*; do > cat $i >> bigfile; rm $i; done" >=20 > That works because I delete each component file as I am recreating > bigfile without going over the free space on my disk. >=20 > 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. >=20 > 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.=