[olug] [Omaha.pm] need some quick help with sed
Christopher Cashell
topher-olug at zyp.org
Fri Dec 18 16:25:26 UTC 2009
On Fri, Dec 18, 2009 at 8:52 AM, Jay Hannah <jay at jays.net> wrote:
>
> postID=`perl -ne 'm#<postID>(.*?)<# && print $1' data.xml`
>
And here's the equivalent of this method in sed:
postID="$(echo `cat ./data.xml | sed -n
's/[[:space:]]*<postID>\([[:digit:]]*\)<\/postID>[[:space:]]*/\1/'p)
This expects the exact tags (case changes in the tags would break it), but
handles any superfluous whitespace at the start or end of the line.
j
--
Christopher
More information about the OLUG
mailing list