Find and Replace a Matching String of Text
Labels:
shell
Find and Replace a Matching String of Text
This script will find all .html files (in the current directory and all subdirectories) and replace the string of text 123 with 456
#!/bin/bsh
for file in $(find . -type f -name '*.html')
do
cat $file |sed "s|123|456|g" > $file.new
mv -v $file.new $file
done
Prefix and escape double quotes with a backslash, (double quotes are used by SED)
#!/bin/bsh
for file in $(find . -type f -name '*.php')
do
cat $file |sed "s|include \"file.php\";|require_once (\'/path/file.php\');|g" > $file.new
mv -v $file.new $file
done
Find and Replace a Matching String of Text
No comments:
Post a Comment