Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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.