I have a file that looks like this:
$variable['keyword1'] = 'value1';
$variable['keyword2'] = 'value2';
$variable['keyword3'] = 'value3';
$variable['keyword4'] = 'value4';
keyword 1-4 are all unique and just letters and numbers.
value 1-4 may or may not be unique and can be any combination of letters, numbers, special characters
I need to be able to extract value1 or value2 or value3 or value4 and save it as $somevariable. So the keyword is obviously the thing that I need to define in the sed command so that I get the desired value out. How would I do that using an sed one liner? Doesn’t look that hard to me but I can’t seem to crack it. Been googling and trying different combinations for hours.
to save it:
if your file is exactly like you describe, you can also use this:
or better yet: (thanks William)