Coding Knowledge Center
Awk
Fields (pattern match) |
INPUT (file.xml):
...
<variable ident="1" type="character">
<title>Don't want this</title>
<variable ident="2" type="single">
<variable ident="3" type="quantity">
...
COMMAND:
> awk '/type="/ {print $3;}' file.xml
OUTPUT:
...
type="character">
type="single">
type="quantity">
...
This will extract all the lines with the type=" pattern and print the 3rd field. Awk defaults to using spaces for the field delimiter.