Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get value of variable config in bash? [duplicate]

Tags:

regex

linux

bash

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.

like image 804
Tomas Pruzina Avatar asked Dec 04 '22 17:12

Tomas Pruzina


1 Answers

You could use the source (a.k.a. .) command to load all of the variables in the file into the current shell:

$ source myfile.config

Now you have access to the values of the variables defined inside the file:

$ echo $VARIABLE
5753
like image 132
Dawngerpony Avatar answered Dec 07 '22 22:12

Dawngerpony