I have a linux config file with with format like this:
VARIABLE=5753
VARIABLE2=""
....
How would I get f.e. value of VARIABLE2 using standard linux tools or regular expressions? (I need to parse directory path from file). Thanks in advance.
I have a linux config file with with format like this:
VARIABLE=5753
VARIABLE2=""
....
How would I get f.e. value of VARIABLE2 using standard linux tools or regular expressions? (I need to parse directory path from file). Thanks in advance.
With
perl
regular expressiongrep
could match these value using lookbehind operator.And for
VARIABLE
:will select the line and evaluate it in the current bash context, setting the variable value. After doing this, you will have a variable named
VARIABLE
with value5753
. If no such line exists in the configfile, nothing happens.You could use the
source
(a.k.a..
) command to load all of the variables in the file into the current shell:Now you have access to the values of the variables defined inside the file: