Script to extract data -

Dave Ihnat dihnat at dminet.com
Wed Apr 13 19:47:48 UTC 2011


On Wed, Apr 13, 2011 at 03:34:41PM -0400, Bob Goodwin wrote:
> I would like to write a script to extract two numbers from the following 
> xml file:

There are *so* many ways to do this; one brute-force approach:

Put the following two commands in a file; let's call it "foo":

  grep "Actual Usage Download" foo | sed -e "s/^.*value=\"//" -e "s/\" .*$//"
  grep "Actual Usage Upload" foo | sed -e "s/^.*value=\"//" -e "s/\" .*$//"

Make the file executable:

  chmod a+rx foo

Then, if your XML file is named bar.xml:

  foo <bar.xml

(If the file isn't in your path, "./foo", etc.)

Cheers,
--
	Dave Ihnat
	dihnat at dminet.com


More information about the users mailing list