Search for and print only matched pattern

Posted by Ayman on Super User See other posts from Super User or by Ayman
Published on 2011-02-09T13:24:02Z Indexed on 2011/02/10 7:27 UTC
Read the original article Hit count: 555

Filed under:
|
|
|

I have some huge xml text files. I need to write a script to find and print a specific tag only. I tried sed and grep but they both return the whole line.

Using SunOS 5.x, so not all linux commands may work. grep -o is not available.

The 'xml' file is not actually one huge xml document, but each line is a separate xml document, with just a few tags, not even nested. And the structure is fairly easy, so full xml parsers is not needed, and probably would not work.

I was looking for sed, awk, or some other one liners, but could not get them to work, and they are both relatively new to me.

© Super User or respective owner

Related posts about search

Related posts about grep