Hi, I've been working on this little search and replace BASH script for a while now and I can't work it out.
#!/bin/bash
# /gp
for var_name in $(egrep -o '\$[^_][a-z0-9_]{2,20}' ./address_edit_logic1.php | egrep -o '[a-z0-9_]+')
do
echo $var_name
echo "s/\\\$$var_name/\\\$PAGE_VARIABLES['$var_name']/g"
sed -e "s/\$$var_name/\$PAGE_VARIABLES['$var_name']/gp" ./address_edit_logic1.php > buffer
echo $var_name
echo " "
#mv buffer test.dat
done
It's supposed to put all my stray variables into one big array called $PAGE_VARIABLES to make debugging the site easier. The first bit works fine, it pulls out the variable name all fine and dandy and if I run the output of
echo "s/\\\$$var_name/\\\$PAGE_VARIABLES['$var_name']/g"
it works that works fine. However if I just run the script it changes nothing.
Any help would be appreciated.
Rob
PS
If anyone knows of any good linux help forums I'd be greatfull. Posted it on JustLinux but others may be helpfull too.