| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
On 2015-12-15 17:40, n22e113 [email protected] [sed-users] wrote:
> Q. How to match the following PHP5 expression?
>
> $CONF['setup_password'] = 'changeme';
>
> Note1: Please provide solution with both sed and grep if able.
> Note2: Would like to replace changeme above.
> Many thanks!
The same regular expression should work for both:
bash$ cat > config.php
echo "Hello!"
$CONF['setup_password'] = 'changeme';
$CONF['something_else'] = 42
^D
bash$ grep "^\$CONF\['setup_password']" config.php
$CONF['setup_password'] = 'changeme';
bash$ sed "/^\$CONF\['setup_password']/s/changeme/newpassword/" config.php
echo "Hello!"
$CONF['setup_password'] = 'newpassword';
$CONF['something_else'] = 42
bash$
-tim