Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Shell script to recursively find files with the same name and replace text within each of them (See related posts)

This shell script recursively finds files with the same name and replaces text within each of them

   1  
   2  FILE="filename.txt"
   3  FIND="old text"
   4  REPLACE="new text"
   5  find . -name $FILE -print0 | xargs -0p perl -pi -w -e "s/$FIND/$REPLACE/g;"


Remove the p flag if confirmation is not necessary.

You need to create an account or log in to post comments to this site.


Click here to browse all 5349 code snippets

Related Posts