Date: Thu, 4 Apr 2002 01:02:11 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: William Gnadt <wgnadt@yahoo.com> Cc: freebsd-questions@freebsd.org, wgnadt@rri-usa.org Subject: Re: help splitting directories Message-ID: <20020403220211.GL848@hades.hell.gr> In-Reply-To: <20020403151902.4403.qmail@web9207.mail.yahoo.com> References: <20020403151902.4403.qmail@web9207.mail.yahoo.com>
index | next in thread | previous in thread | raw e-mail
On 2002-04-03 07:19, William Gnadt wrote:
> Hi:
>
> I can generate the following output from find,
>
> > cd /usr/ports/distfiles
> > find . -type f -ls | awk '{print $7,$11}' -
> 731400 ./bison-1.34.tar.gz
> 20288222 ./emacs-21.2.tar.gz
> 226817 ./procmail-3.22.tar.gz
> 497341 ./john-1.6.tar.gz
> 497716 ./epic4/epic4-1.0.1.tar.bz2
> 216319 ./epic4/epic4pre2-help.tar.gz
> 521458 ./links-0.97pre7.tar.gz
> 154700 ./micq-0.4.6.p1.tgz
> 428767 ./cvsup-snap-16.1f.tar.gz
> 121835 ./pidentd-2.8.5.tar.gz
> ...
>
> I'd like some pointers on splitting this list
> into smaller lists after the sum of file sizes
> reaches a fixed threshold (say ~100MB for copying
> to zip disks).
You can use awk, with something like:
find ... | awk -v splitlen=629145600 -f script.awk
where script.awk has stuff like this:
% cat script.awk
BEGIN {
rlen = 0;
}
{
if ((rlen + $1) > splitlen) {
print "---";
rlen = 0;
} else {
rlen += $1;
}
print $0;
}
This will insert "---" separators at the right places in the output of
find. Then you can split at those separators :)
PS: I haven't checked the awk script above, so it might have typos or
errors. Use at your own risk.
Giorgos Keramidas FreeBSD Documentation Project
keramida@{freebsd.org,ceid.upatras.gr} http://www.FreeBSD.org/docproj/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020403220211.GL848>
