Script to extract data -

Cameron Simpson cs at zip.com.au
Sat Apr 16 00:49:48 UTC 2011


On 15Apr2011 04:34, Bob Goodwin <bobgoodwin at wildblue.net> wrote:
| On 14/04/11 19:09, Cameron Simpson wrote:
| >On 13Apr2011 16:11, Bob Goodwin<bobgoodwin at wildblue.net>  wrote:
| >| On 13/04/11 15:47, Dave Ihnat wrote:
| >|>  [ grep | sed approach ... ]
| >|
| >|         [bobg at box9 ~]$ grep "Actual Usage Download" /home/bobg/foo | sed
| >|         -e "s/^.*value=\"//" -e "s/\" .*$//"
| >|         12667
| >|
| >|         Aha, that works. It's so much easier when you can find someone
| >|         who knows how!
| >|
| >|         As I said I can muddle through from there, that was the hard part.
| >
| >Never forget that sed can do what grep does, so (untested, one line):
| >
| >   sed -n '/Actual Usage Download/s/.*value="\([^"]*".*/\1/p'<  /home/bobg/foo
| >
| >Cheers,
| 
| 
|        This morning's data:
| 
|        [bobg at box9 ~]$ cat foo
|        <graph caption="Customer: bobgoodwin at wildblue.net"
|        xaxisname="Figures Shown Reflect Data Usage in the Last 30 Days"
|        yAxisName="Data Usage" bgColor="E3ECF6" showGridBg="1"
|        showCanvas="1" numdivlines="4" decimalPrecision="0"
|        zeroPlaneColor="CCCCCC" zeroPlaneAlpha="40" numberSuffix="MB">
|        <set name="Actual Usage Upload" value="1094" color="007CC2"/>
|        <set name="Usage Threshold Upload" value="5000" color="9CA279"/>
|        <set name="Actual Usage Download" value="12012" color="007CC2"/>
|        <set name="Usage Threshold Download" value="17000" color="9CA279"/>
|        </graph>
| 
| 
|        [bobg at box9 ~]$ sed -n '/Actual Usage
|        Download/s/.*value="\([^"]*".*/\1/p' < /home/bobg/foo
|        sed: -e expression #1, char 49: Unmatched ( or \(
| 
|        I thought perhaps a permissions problem?

No, an unmatched bracket in the expression. Try this:

  sed -n '/Actual Usage Download/s/.*value="\([^"]*\)".*/\1/p' < /home/bobg/foo

All on one line, if the above gets folded.
Note the closing \) I've added.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

What the hell is that?
Sounds like Cole Porter to me, sir.     - _Tank Girl_


More information about the users mailing list