Issue
I'd like to removed a semicolon from one of these lines in the php.ini using bash shell command (perhaps using sed
). How would I do that?
;extension =php_curl.dll
; extension=php_gd2.dll
;extension = php_mbstring.dll
;extension= php_openssl.dll
I intentionally added spaces here and there.
What I've tried:
sed -e "s/^;extension\s=\sphp_gd2\.dll$/extension=php_gd2\.dll/" -i php.ini
This just places everyting into a single line:
;extension =php_curl.dll ; extension=php_gd2.dll;extension = php_mbstring.dll;extension= php_openssl.dll
Solution
This removes a semicolon at the beginning of a line that has one or more spaces on both sides
sed '/php_gd2/s/^\s\s*;\s\s*//' php.ini
You can specify which php extension you want to operate on by putting it in between slashes at the beginning. Then it will run the substitute command only on the lines that have the specified extension
To be even more selective,
sed '/^\s*;\s*extension\s*=\s*php_gd2.*\.dll/s/^\s\s*;\s\s*//' php.ini
Answered By - ramana_k Answer Checked By - Cary Denson (WPSolving Admin)