Hi,
There's a long sentence from which I need to extract only the part which is at the right side of the word LENGTH i.e. 15
long sentence :
<INPUT VAR1 ="" DATATYPE ="number(p,s)" VAR2 ="" VAR3 ="3" VAR4="0" VAR5 ="ELEMITEM" VAR6 ="NO" VAR7 ="NOT A KEY" VAR8 ="17" LEVEL ="0" NAME ="UNIX" NULLABLE ="NOTNULL" OCCURS ="0" OFFSET ="19" LENGTH ="15" PHYSICALOFFSET ="29" PICTURETEXT ="" PRECISION ="15" SCALE ="0" USAGE_FLAGS =""/>
I could do the following
cat $file_with_the_long_sentence | awk '{ if ($0 ~ "LENGTH") { print $33} }'
but the part that is worrying me is
{ print $33} }
as it might vary so not neccessarily I would have LENGTH at the 33rd field....also I can't use space (" ") as the field-separator as it is clear that there's space even between the variable (LENGTH) and the assignment operator (=).
Can someone please suggest a flexible way to do this?
-dips