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.
116
April 4, 2013, 8:31am
3
echo $line | sed 's/.*TYPE \(="[^"]*"\).*/\1/'
Perfect, thank you very much
Jotne
April 4, 2013, 10:10am
5
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