Issue
I have a line I want to replace such as
'baseurl' => 'https://231.231.231.231'
But I only want it to replace the https://231.231.231.231 part.
Basically I want it to be
'baseurl' => 'myvaluehere'
I have tried sudo sed -i "s|'baseurl'|${value1}|g" file.php
How do I replace after certain characters after 'baseurl' is matched?
Solution
Using sed
$ sed -E "/(baseurl'[^']*')[^']*/s//\1myvaluehere/" input_file
'baseurl' => 'myvaluehere'
Answered By - HatLess Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.