Find & Replace string
Nathan Kinkade
nkinkade at ub.edu.bz
Thu Dec 9 10:13:57 PST 2004
On Thu, Dec 09, 2004 at 10:48:06AM -0600, antenneX wrote:
> Help on commands/script needed.
>
> 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"
>
> What's the best way to do this?
>
> Thanks in advance!
>
> Best regards,
>
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20041209/55265abe/attachment-0001.bin
More information about the freebsd-questions
mailing list