Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

Shell Find and Replace across Multiple files

Dawn Rossi, 01-04-2008
If you're on a shell and need a quick way to do Find & Replace on multiple files, this one-liner is the easiest way to get the job done:


find
. -name '*.html' -print0 | xargs -0 perl -pi -e 's/FINDSTRING/REPLACESTRING/g'

Set FINDSTRING to the string you would like to find and REPLACESTRING to the replacement string.

Be sure to prefix any special character ()[]/"'!? etc with a backslash

Stephane, 01-05-2008
Thank you, that will sure come in handy someday.

Gotta note that down, I'll never remember that...

Dawn Rossi, 01-06-2008
Thanks Stephane, Glad you liked it!
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions