I'm trying to convert an ini file into bash array variables. The sample ini is as below
[foobar]
session=foo
path=/some/path
[barfoo]
session=bar
path=/some/path
so these become
session[foobar]=foo
path[foobar]=/some/path
session[barfoo]=bar
and so on.
Right now, I could come up with only this command
awk -F'=' '{ if ($1 ~ /^\[/) section=$1; else if ($1 !~ /^$/) print $1 section "=" $2 }'
Also, another problem is, it doesn't take spaces near = into consideration. I think sed is probably better suited for this job but I don't know how to hold and store a temporary variable for the section name in sed.
So any idea how to do this?