The script is not working as expected. At the moment, I don't understand why. The purpose of the script is to find and replace text within several hundred files under /var/www/moin/mywiki.
The third line from the bottom works perfectly, the uncommented find command. This is the result:
The bottom line, the comented find command (if uncommented of course) does not give the expected results. It appears to work. There is no output at all but when I run the simple find command again the text is unchanged. What am I overlooking?
By the way, there are 668 instances of $search_text that need to be replaced with $replace_text.
PHP Code:
#!/bin/bash
# moin_find_highlight.sh
# Find and replace text within MoinMoin page files
# Glenn A. Johnson
# Started November 13, 2012
# Last edited November 13, 2012
# Source my include files
. scolors # Color text
. includes # Various functions
# Variables
search_path="/var/www/moin/mywiki/"
search_file="*000*"
search_text="highlight bash"
replace_text="shell"
# Need root permissions
get_root # Call a function from my include file
find $search_path -type f -name $search_file -exec grep "$search_text" {} ;
# It appears that the below line didn't work as expected.
#find $search_path -type f -name $search_file -exec sed -i 's/"$search_text"/"$replace_text"/g' {} \;
PHP Code:
#!highlight bash
{{{#!highlight bash
#!highlight bash
{{{#!highlight bash
#!highlight bash
#!highlight bash
#!highlight bash
#!highlight bash
#!highlight bash
{{{#!highlight bash
#!highlight bash
{{{#!highlight bash
#!highlight bash
#!highlight bash
By the way, there are 668 instances of $search_text that need to be replaced with $replace_text.