From owner-freebsd-questions@FreeBSD.ORG Thu Jan 28 10:27:39 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62C8F1065670 for ; Thu, 28 Jan 2010 10:27:39 +0000 (UTC) (envelope-from perrin@apotheon.com) Received: from outbound-mail-111.bluehost.com (outbound-mail-111.bluehost.com [69.89.18.7]) by mx1.freebsd.org (Postfix) with SMTP id 30F1C8FC1E for ; Thu, 28 Jan 2010 10:27:39 +0000 (UTC) Received: (qmail 12861 invoked by uid 0); 28 Jan 2010 10:27:38 -0000 Received: from unknown (HELO box543.bluehost.com) (74.220.219.143) by outboundproxy3.bluehost.com with SMTP; 28 Jan 2010 10:27:38 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=apotheon.com; h=Date:From:To:Subject:Message-ID:Mail-Followup-To:References:Mime-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-Identified-User; b=aYFQ7Cm+r1GBEdpkhDGzdmznxa1/FF3ZwHwL5qzOjvlELMJxh/OBWmzugLhlZpi93bQ9muSFzqE5uVIjb5WJgqDsjFoM+/K74IQ2o8aYoa1n2hyjvVaQdX2BZuqIKr2h; Received: from c-24-8-180-234.hsd1.co.comcast.net ([24.8.180.234] helo=kukaburra.hydra) by box543.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NaRb7-00025e-He for freebsd-questions@freebsd.org; Thu, 28 Jan 2010 03:27:38 -0700 Received: by kukaburra.hydra (sSMTP sendmail emulation); Thu, 28 Jan 2010 03:19:21 -0700 Date: Thu, 28 Jan 2010 03:19:21 -0700 From: Chad Perrin To: freebsd-questions@freebsd.org Message-ID: <20100128101921.GA28664@guilt.hydra> Mail-Followup-To: freebsd-questions@freebsd.org References: <4B6090FC.4070002@gmail.com> <20100128101351.GA27490@guilt.hydra> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline In-Reply-To: <20100128101351.GA27490@guilt.hydra> User-Agent: Mutt/1.4.2.3i X-Identified-User: {2737:box543.bluehost.com:apotheon:apotheon.org} {sentby:smtp auth 24.8.180.234 authed with ren@apotheon.org} Subject: Re: OT: finding every file not in a list X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2010 10:27:39 -0000 --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 28, 2010 at 03:13:51AM -0700, Chad Perrin wrote: >=20 > losers =3D Dir["#{Dir.getwd}/**/*"] > keepers =3D IO.readlines ARGV.shift > startpath =3D ARGV.shift >=20 > if startpath > Dir.chdir startpath > end Oops. Speaking of using at your own risk . . . That line that reads `losers =3D Dir["#{Dir.getwd}/**/*"]` should be *after* the conditional block. Thus, the above quoted code should look like this instead: keepers =3D IO.readlines ARGV.shift startpath =3D ARGV.shift =20 if startpath Dir.chdir startpath end losers =3D Dir["#{Dir.getwd}/**/*"] =2E . . otherwise you might end up deleting a bunch of files in the wrong part of the directory hierarchy if you execute the program from somewhere other than where you want files deleted. I guess I shouldn't have gotten fancy and tried to provide a way to execute it from anywhere in the filesystem. Sorry about that. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --OXfL5xGRrasGEqWY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkthZKkACgkQ9mn/Pj01uKVngACcCdUmbu49vcWzGmAfgOmQjJR1 6+EAnAmrDaoMIRwegXXVyALzeNwRTSy6 =EjdG -----END PGP SIGNATURE----- --OXfL5xGRrasGEqWY--