/ Published in: Bash

Nix search replace using sed
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
!/bin/bash FOLDER="/Users/path/to/test/original/" echo "******************************************" echo enter word to replace read searchterm echo enter word that replaces read replaceterm for file in $(grep -l -R $searchterm $FOLDER) do sed -e "s/$searchterm/$replaceterm/g" $file > /Users/path/to/test/tmp/tempfile.tmp mv /Users/path/to/test/tmp/tempfile.tmp $file echo "Modified: " $file done echo " *** All Done! *** "
Comments
