Link to home
Start Free TrialLog in
Avatar of credog
credog

asked on

Sed question

I was looking a a sed command online (which seems to work fine) and didn't understand why the recommended solution included a [^>].  I don't think it's needed, so I was hoping someone could explain why the poster may have thought it was.   Here's the jist of the questions an recommended solution.

User had a xml file which was all on one line (for clarity it's broken up into multiple lines below) and looked something like this:
<Point><Time>2014-02-12T18:18:49+11:00</Time>
<Position><Lat>35.209656</Lat><Lon>28.99924</Lon></Position>
<AltMeters>586.99994</AltMeters>
<DisMeters>148.30713</DisMeters>
<Cad>4</Cad>
</Point>

Open in new window

The user wanted to remove all occurrences of <DisMeters>.....</DisMeters> from the line in the file.  The recommended solution which seems to work fine was:
sed 's/<DisMeters>[^>]*>//g' file

Open in new window

Why include the [^>], which negates the >?  Doesn't seem needed or am I missing something?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of credog
credog

ASKER

Great explanation.