Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a xml file like this:

<field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/>
<field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000201000 seconds" size="0" pos="0" show="0.000201000"/>
<field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000595000 seconds" size="0" pos="0" show="0.000595000"/>

I want to grep all the values in the show="xxx" part, the output would be:

0.000000000
0.000201000
0.000595000
...

is it possible to do that by using grep?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
grep -Po '(?<=show=")[^"]*' filename.xml

(?<=show=")[^"]* matches xxxx in show="xxxx" and grep option -o prints only those text matched.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.