Over a million developers have joined DZone.

One-line Shell Script For Find And Replace

·
An equivalent of the other find-replace, except it's a one-liner that generates no temp files, and is more flexible:


perl -pi -e 's/find/replace/g' *.txt


Or, to change matching files in a hierarchy:


find . -name '*.txt' |xargs perl -pi -e 's/find/replace/g'
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}