[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] [olug] need some quick help with sed



On Dec 18, 2009, at 12:58 AM, DYNATRON tech wrote:
> i'm trying to strip an xml value into a variable in a bash script.
> 
> postID="$(echo `cat ./data.xml | grep postID`)"
> 
> but this gives me the entire line:    <postID>999999</postID>
> 
> i need $postID to equal 999999 and i've been trying to learn how to do this
> with sed, but anything i try just outputs the entire line with the xml tags.
> any suggestions? after 10 hours of coding in one day sed tutorials are just
> making my head spin.

postID=`perl -ne 'm#<postID>(.*?)<# && print $1' data.xml`

Merry holidays and a festive not working to all,

j
Omaha Perl Mongers: http://omaha.pm.org