Re: How To Match: $CONF['setup_password'] =

"Tim Chase [email protected] [sed-users]" <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.