Bash – sed php.ini memory_limit

bashphp.inised

The following works great:

phpmemory_limit=256M #or what ever you want it set to
sed -i 's/memory_limit = 16M/memory_limit = '${phpmemory_limit}'/' /etc/php5/apache2/php.ini

If the memory_limit is set to 16M, but I've found that in some distributions it doesn't default to 16M, but instead will default to 32M. So my question is how to I have SED account for that and replace whatever the number is to ${phpmemory_limit}?

Best Answer

you can use regexp - for instance:

phpmemory_limit=256M #or what ever you want it set to
sed -i 's/memory_limit = .*/memory_limit = '${phpmemory_limit}'/' /etc/php5/apache2/php.ini