I have a phppgadmin configuration file (/usr/share/phppgadmin/conf/config.inc.php)
It has a line:
$conf['extra_login_security'] = false;
I would like to change it to:
$conf['extra_login_security'] = true;
using bash shell-script. I understand that I would have to use something like sed/awk. But don’t know how exactly to use it to do what I want.
If you want a simple global substitution of false to true then
sed 's/false/true/g'will do it.However to only change lines the start with
conf[and just change the value to true then this is bettersed 's/\(^.*conf\[.*\] =\) false/\1 true/g'EDIT:
Just that line can be done with the following:
sed -i 's/\(^.*conf\[.extra_login_security.\] =\) false/\1 true/' /usr/share/phppgadmin/conf/config.inc.phpUse
-ito save the changes to the file, or redirect to a new file if you don’t want to overwrite the original.sed 's/\(^.*conf\[.extra_login_security.\] =\) false/\1 true/' > mynewfile.phpA trick if you don’t have permission to write
mynewfile.phpis to pipe the output toteeandsudothat:sed 's/\(^.*conf\[.extra_login_security.\] =\) false/\1 true/' | sudo tee mynewfile.phpFrom
man teetee – read from standard input and write to standard output and files.