unix command

hi frnds,

i have my file like this

<REALTION>
dd
dd
dd
</REALTION>
...
<REALTION>
hh
hh
</REALTION>

i want to pick only 6th REALTION block. what command i can use ?

Following should be what you're after - output you see here is from a quick test file where each block contains a couple of lines in form nn where n = block:

#  awk '/<REALTION/{t+=1}t==6{print}' file
<REALTION>
66
66
</REALTION>

HTH

If there is something between such a <REALTION> </REALTION> block it will be printed out too, ie. his ... lines for example.

I have a bit cumbersome solution:

awk '
     /^<REL/ {z++; if(z==6){print $0; f=1; next}}
     $0 !~ /^<\/REL/ && f==1 {print $0}
     $0 ~ /^<\/REL/ && f==1 {print $0; f=0}
' z=0 f=0 infile

Input:

<RELATION>
1
</RELATION>
...
<RELATION>
2
</RELATION>
...
<RELATION>
3
</RELATION>
...
<RELATION>
4
</RELATION>
...
<RELATION>
5
</RELATION>
...
<RELATION>
6
66
666
</RELATION>
...
<RELATION>
7
</RELATION>
...
<RELATION>
8
</RELATION>

Output:

<RELATION>
6
66
666
</RELATION>

true... so this should be cleaner:

#   nawk '
/^<REAL/ {t++}
t==6 {print}
/^<\/REAL/ && t==6 {t++}
' file