LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   String manipulation (https://www.linuxquestions.org/questions/linux-newbie-8/string-manipulation-481075/)

Manuel Alvarado 09-06-2006 06:50 PM

String manipulation
 
Hello,

I'm looking for a linux command to extract specific strings from an xml documents. For example, the following string:
<name>John Doe</name>

I have tried "grep", but this produces the entire line of text which is too much to handle or to focus on. I will appreciate any possible help!

Thanks!

Manuel Alvarado:Pengy:

bulliver 09-06-2006 06:53 PM

Have a look at sed and awk.
Perl, Python or Ruby would be suitable as well if you know them.

Your life would likely be much easier if you picked a scripting language and used one of the many XML libraries available...

makyo 09-06-2006 09:49 PM

Hi.
Quote:

Originally Posted by Manuel Alvarado
I'm looking for a linux command to extract specific strings from an xml documents. For example, the following string:
<name>John Doe</name>

I have tried "grep", but this produces the entire line of text which is too much to handle or to focus on.

Many people find this of some use:
Code:

      -o, --only-matching
              Show only the part of a matching line that matches PATTERN.
-- excerpt from man grep

For more flexibility, you might, as bulliver noted, need to consider a scripting language ... cheers, makyo


All times are GMT -5. The time now is 07:09 PM.