Date: Thu, 28 Jan 2010 03:19:21 -0700 From: Chad Perrin <perrin@apotheon.com> To: freebsd-questions@freebsd.org Subject: Re: OT: finding every file not in a list Message-ID: <20100128101921.GA28664@guilt.hydra> In-Reply-To: <20100128101351.GA27490@guilt.hydra> References: <4B6090FC.4070002@gmail.com> <20100128101351.GA27490@guilt.hydra>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100128101921.GA28664>
