[Solved] Search for a word and print the next word

Hi,

I am trying to search for a word and print the next word. For example:

My text is "<TRANSFORMATION TYPE ="Lookup Procedure">"

I am searching for "TYPE" and trying to print ="Lookup Procedure"

I have written a code like following:

echo $line | nawk '{for(i=1;i<NF;i++){if($i~/^TYPE/){print $(i+1)}}}'

But the output is coming as "Lookup

Please help, thanks

sed is ideal for these kind of things:

echo $line | sed 's/.*TYPE ="\([^"]*\)".*/\1/'

Guru.

 
echo $line | sed 's/.*TYPE \(="[^"]*"\).*/\1/'

Perfect, thank you very much

Is this a long list of lines, and you need a text that is on the same location on the line, its faster to search for the text you like and then print a specific position.
Like this:

awk -F\" '/TYPE/ {print $2}' File
Lookup Procedure