[kwlug-disc] wget and variable assignment

Raul Suarez rarsa at yahoo.com
Thu Jun 3 13:05:33 EDT 2010


Why not wgetting to a temporary file, loading it to a var and processing it several times?

Or if you want to reduce HDD access, once you get the file, you could load the file to a variable and process it as much as you want.

fullPage=`cat data_stats.html`


Raul Suarez

Technology consultant
Software, Hardware and Practices
_________________
Twitter: rarsamx
http://rarsa.blogspot.com/ 
An eclectic collection of random thoughts


--- On Thu, 6/3/10, Richard Weait <richard at weait.com> wrote:

> From: Richard Weait <richard at weait.com>
> Subject: [kwlug-disc] wget and variable assignment
> To: "KWLUG discussion" <kwlug-disc at kwlug.org>
> Received: Thursday, June 3, 2010, 12:58 PM
> I have a simple screen-scrape to do.
> 
> >From the command line it works fine
> 
> wget -q -O - http://www.openstreetmap.org/stats/data_stats.html|
> grep
> "<td>Number of users" | sed -e 's/[:a-zA-Z
> <>/:]//g'
> 
> it returns the plain number
> 
> 262086
> 
> Cool, now to add it to a script
> 
> This works fine
> GETTEE=`wget -q -O -
> http://www.openstreetmap.org/stats/data_stats.html|
> grep "<td>Number
> of users" | sed -e 's/[:a-zA-Z <>/:]//g'`
> echo "GETTEE = $GETTEE"
> 
> gives:
> GETTEE = 262086
> 
> But.  I want to grab some other data from the same
> page, so I want to
> wget once, then grep / sed a couple of times.  And I'm
> breaking it.
> The page appears to have been stripped of its \n and so
> grepping the
> line I want is failing.
> 
> GETTEE=`wget -q -O - http://www.openstreetmap.org/stats/data_stats.html`
> echo "GETTEE = $GETTEE"
> 
> This returns a mess.
> 
> The quick and dirty is to wget four times for four numbers,
> but I
> don't want to do that.  How do I assign the wget to a
> variable and
> keep \n ?
> 
> _______________________________________________
> kwlug-disc_kwlug.org mailing list
> kwlug-disc_kwlug.org at kwlug.org
> http://astoria.ccjclearline.com/mailman/listinfo/kwlug-disc_kwlug.org
> 





More information about the kwlug-disc_kwlug.org mailing list