Assume this .ini file.
[section_x]
my_value=abc
another_value=def
[section_2]
my_value=stv
another_value=xyz
[this_one]
my_value=something
another_value=sure
Assume the system has the value something loaded in it's environment variable.
Using bash, how can I search the .ini file to match the value, and then load that section, in this case this_one? Based on the section, it then loads another_value.
In this case, the outcome would be sure.
Another example for clarity: if the system had stv loaded in it's env, the outcome is xyz.
As long as
$variabledoesn't contain anything special, you can use awk in "paragraph mode":Alternatively, in case
grepdoesn't support-Por negative lookbehinds: