I need to have an array for each \"section\" in the file containing:
[array0]
value1=asdf
value2=jkl
[array1]
value1=1234
value2=5678
I want t
I am about to go out, but I think you can do something like this (untested) and maybe someone clever , like @anubhava, will pick it up and finish it off...
eval $(gawk -F= '/^\[/{name=gensub(/\[|\]/,"","g");x=0} /=/{print "name[",x++,"]=",$2," "}' config)
Basically, when it sees a line starting with "[
" it picks up the array name in the variable name
and strips off the square brackets with gensub()
. Then, when it sees a line with "=
" in it, it outputs the array name and an increasing index "x
" for eval
to pick up.
Gotta dash - look at the examples for stat -s
here.