I wrote a bash script which can modify php.ini according to my needs.
Now I have to introduce a new change, and I cannot find a clear solution to it.
I need to
This might work for you:
sed '/^; Dynamic Extensions ;$/,/^; Module Settings ;$/{H;//{x;/extension="memcache.so"/{p;d};/;;;\n/{s//&extension="memcache.so"\n/p}};d}' file
This will insert extension="memcache.so" between ; Dynamic Extensions ; and ; Module Settings ; unless extension="memcache.so" is already present.