how to pull only values from the xml tags?
I have a file test.txt
Code:
cat test.txt e.g. 1. to pull value in <ACQ_message> i tried: $ sed -n "/P1584/,/<\/data_block>/p" "test.txt"|grep "<ACQ_message>"|awk -F ' ' '{print $2}'|cut -c25-35 output: Y what is the best way to get only value inside the <ACQ_message>? removing leading and trailing spaces, because value could be of any long characters 2. similar way i want to pull only value inside the <ACQ_Found> tag, however i tried: $ sed -n "/P1584/,/<\/data_block>/p" "test.txt"|grep "<ACQ_Found>"|awk -F '-' '{print $3}' output: 05:30</ACQ_Detail><ACQ_Found> 5</ACQ_Found> could someone please help? |
do not use sed|grep|awk|cut chains, usually it can be solved with a single sed or awk or perl or ....
Anyway probably an xml parser would be a better idea. http://stackoverflow.com/questions/4...ng-shellscript |
Yeah, I'd also go with something meant for parsing XML (like Python's ElementTree, but there are undoubtedly many choices).
|
Quote:
|
glad to help you
|
All times are GMT -5. The time now is 09:20 PM. |