From owner-freebsd-questions Wed Apr 3 14: 8:54 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 8B46E37B41A for ; Wed, 3 Apr 2002 14:08:45 -0800 (PST) Received: from hades.hell.gr (patr530-b233.otenet.gr [212.205.244.241]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g33M8ZbP019174; Thu, 4 Apr 2002 01:08:37 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.2/8.12.2) with ESMTP id g33M8eci003031; Thu, 4 Apr 2002 01:08:41 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from charon@localhost) by hades.hell.gr (8.12.2/8.12.2/Submit) id g33M2CiN002884; Thu, 4 Apr 2002 01:02:12 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Thu, 4 Apr 2002 01:02:11 +0300 From: Giorgos Keramidas To: William Gnadt Cc: freebsd-questions@freebsd.org, wgnadt@rri-usa.org Subject: Re: help splitting directories Message-ID: <20020403220211.GL848@hades.hell.gr> References: <20020403151902.4403.qmail@web9207.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020403151902.4403.qmail@web9207.mail.yahoo.com> User-Agent: Mutt/1.3.28i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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