I have a file that starts like this:
[global]
pid = /var/run/php-fpm/php-fpm.pid
error_log = /var/log/php5-fpm.log
and want to replace
error_log = /var/log/php5-fpm.log
with
error_log = /var/log/php-fpm/error.log
I want to use a script for that and did the following:
search='error_log = /var/log/php5-fpm.log'
replace='error_log = /var/log/php-fpm/error.log'
for file in `find -name 'php-fpm.conf'`; do
grep "$search" $file &> /dev/null
if [ $? -ne 0 ]; then
echo "Search string not found in $file!"
else
sed -i "s#$search#$replace#" $file
fi
done
That throws this errors:
sed: -e expression #1, char 0: no previous regular expression sed: -e expression #1, char 0: no previous regular expression