Date: Thu, 9 Dec 2004 12:13:36 -0600 From: Nathan Kinkade <nkinkade@ub.edu.bz> To: antenneX <antennex@swbell.net> Cc: freebsd-questions@freebsd.org Subject: Re: Find & Replace string Message-ID: <20041209181336.GA3650@gentoo-npk.bmp.ub> In-Reply-To: <019101c4de0e$dbdeb2d0$0200000a@SAGEAME> References: <019101c4de0e$dbdeb2d0$0200000a@SAGEAME>
next in thread | previous in thread | raw e-mail | index | archive | help
--O2g7+miYGsIKoR9l Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 09, 2004 at 10:48:06AM -0600, antenneX wrote: > Help on commands/script needed. >=20 > In a website of 1.GB+ with several hundred thousand files, I need to > interrogate all files to replace a single string like "oldone.010" with > "newone.011" >=20 > What's the best way to do this? >=20 > Thanks in advance! >=20 > Best regards, >=20 > Jack L. Stone Are you talking about changing the name of the file itself, or a string within the file? If it's the former then a shell for loop work. Maybe something like: $ for file in $(find /somedir -name "*.010"); \ do mv $file $(echo $file | sed -e 's/oldone/newone'); \ done If the latter, then using perl, perhaps with the -e -i switches, might work well. man perlrun(1) for some tips. Nathan --O2g7+miYGsIKoR9l Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBuJXQO0ZIEthSfkkRArVxAJ996SUSenvWztB6wzwdhF0Y01R34QCg7Qw2 f4FvTNJIbL3v/0jrmHyj4aU= =dyjE -----END PGP SIGNATURE----- --O2g7+miYGsIKoR9l--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041209181336.GA3650>