replacing a line that may have different values on different servers

Replace disable_functions in php.ini with value of your choice which may be different on different servers

-bash-2.05b# grep disable_functions /usr/local/lib/php.ini
disable_functions = 1 2 e weq t ret rye y etyhty rt et e

-bash-2.05b# replace "$(grep disable_functions /usr/local/lib/php.ini)" "disable_functions = exec" -- /usr/local/lib/php.ini | grep disable_functions

-bash-2.05b# grep disable_functions /usr/local/lib/php.ini
disable_functions = exec

I was successful above, but how to do it the awk or sed way?

Thanks

With sed:

sed 's/disable_functions = .*/disable_functions = exec/' php.ini > file.tmp
mv file.tmp php.ini

If your sed version support the -i option:

sed -i 's/disable_functions = .*/disable_functions = exec/' php.ini

With awk:

awk '$0 ~ /disable_functions = /{print "disable_functions = exec";next}1' php.ini > file.tmp
mv file.tmp php.ini

Regards

substitute="newstring"
while read line
do
    case $line in 
        "disable_functions"* ) echo "disable_functions = $substitute";; 
        *) echo $line;;       
    esac
done < php.ini > newphp
mv newphp php.ini

Kool... thanks a lot.