Hi there,
i'm having some problems just making an awk script (i've tried this way, but other way can be posible for sure), for the next file
file.txt
<register>
<createProfile>
<result>0</result>
<description><![CDATA[OK]]></description>
<msisdn>34661461174</msisdn>
<inputOmvID>1</inputOmvID>
<inputGroupID>-2</inputGroupID>
<ProfileOmvID>1</ProfileOmvID>
<contentID>3365</contentID>
<contentProfileID>3525</contentProfileID>
<chargingProfileTypeId>22</chargingProfileTypeId>
<operationID>201022</operationID>
...
i have to test if
<createProfile> is in the file. If it does, then i have to extract the lines
<msisdn>34661461174</msisdn>
and
<contentProfileID>3525</contentProfileID>
so i've tried staring with something like this
>
awk '/^<createProfile>/{getline;print}' file.txt
but this only print the next line to the matching pattern
<createProfile>.
With this script
> awk '/^<createProfile>/ {print NR,$0}' file.txt
i get the line where he regex matches, bu i don't know how to go on to print the registers for
<msisdn>34661461174</msisdn> and
<contentProfileID>3525</contentProfileID>
The file is always this way of structure, i mean all the tags are in the same position if the first matching pattern is matched
.
Thank you for any help