Can someone help me get a substring using a sed program?
I have a file with this line:
.... define("BASE", "empty"); # there can be any string (not only "empty"). ....
And I need to get "empty" as a string variable for my bash script.
At this moment I have:
sed -n '/define(\"BASE\"/p' path/to/file.ext # returns this line: # define("BASE", "empty"); # but I need 'empty'
UPD: Thanks @Jaypal
At the moment I have a bash script:
DBNAME=`sed -n '/define(\"BASE\"/p' path/to/file.ext` echo $DBNAME | sed -r 's/.*"([a-zA-Z]+)".*/\1/'
It works fine, but if there is a way to do the same manipulation with a single line of code?
source share