file traversal

Hi,
I have to get some value of the from a flat file and my file format is like this.

        ABC
          DEF
            HIJ=1

        XYZ
          xyz
            HIJ=2

So i need to make sure i get all the value of HIJ under XYZ and not ABC.

Hi

$ awk -F= 'f && /HIJ/{print $2;f=0}/XYZ/{f=1;}' file
2

Guru.

thanks Guru. I need to get more out of it.
A
a=1
b=2
c=3
d=4

B
a=1
b=2
c=3
d=4

I need all the value of the vars from B and not A and print values in
tabular format(\t). Please explain the command so that i can tweak it.

I wonder at times why people give their requirements in installments!! Please provide the exact requirement at the first instance itself:

$ awk -F= 'f{x=x?x"\t"$2:$2;}/B/{f=1;}/^$/{f=0}END{print x}' file
1       2       3       4

We set a flag variable 'f' to 1 when the pattern B is encountered. Once f is 1, we accumulate all the values in a variable "x". And the variable is printed at the end.

Guru.

sorry about that...thanks alot for your time