Re: sed help please

From: Barry Finkel (b19141@ACHILLES.CTD.ANL.GOV)
Date: Thu Feb 13 2003 - 11:26:46 EST


>Hi all;
>
>I have script almost finished however 1 little aspect has me stumped - would
>someone be so kind as to provide me with a little help.
>
>This is what my infile looks like (performance toolbox data):
>
>^L"#Monitor: xmservd recording --- hostname: c2f1n1ex"
>"Timestamp" "PagSp/totalfree" "PagSp/totalsize" "Mem/Virt/pageout"
>"Mem/Virt/pag
>ein" "Mem/Real/%free" "Mem/Real/numfrb" "CPU/cpu3/idle" "CPU/cpu2/idle"
>"CPU/cpu
>1/idle" "CPU/cpu0/idle"
>"2003/01/30 07:04:01" 474683 524288 3 13 0.9
>226
>2 98.3 98.2 98.2 98.1
>"2003/01/30 07:09:01" 474683 524288 6 0 1.0
>284
>2 94.7 98.2 96.7 98.2
>"2003/01/30 07:14:01" 474683 524288 4 0 1.0
>276
>4 99.6 99.2 98.2 98.9
>
>
>
>This is what my CURRENT outfile looks like:
>
>2003/01/30 7:04:01,474683,524288,3,13,0.9,2262,98.3,98.2,98.2,98.1
>2003/01/30 07:09:01,474683,524288,6,0,1.0,2842,94.7,98.2,96.7,98.2
>2003/01/30 07:14:01,474683,524288,4,0,1.0,2764,99.6,99.2,98.2,98.9
>2003/01/30 07:19:01,474683,524288,3,0,1.0,2549,99.6,99.7,98.2,99.5
>2003/01/30 07:24:01,474683,524288,2,0,1.0,2539,99.5,99.8,98.3,99.8
>
>Here is what I have so far for a script:
>
>sed -e "s!\"!!g
> /[A-Za-z]\{1,\}.*/d
> s? \{3,\}?,?g" infile > outfile
>
>I need to have the hostname added to every line of output, however, the
>hostname only appears 1x at the top of the infile and is not repeated (as
>all the other fields are) on everyline of data.
>
>Please help, I'm running out of hair to pull out!

I am not a sed expert. What I would do is somehow get the hostname
into the first line of the output, and then feed the output through
a short awk script to propogate the hostname to the subsequent lines.
Would this sed line

     [1]=

write the contents of the first line intact without any changes?
----------------------------------------------------------------------
Barry S. Finkel
Electronics and Computing Technologies Division
Argonne National Laboratory Phone: +1 (630) 252-7277
9700 South Cass Avenue Facsimile:+1 (630) 252-4601
Building 222, Room D209 Internet: BSFinkel@anl.gov
Argonne, IL 60439-4828 IBMMAIL: I1004994



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:35 EDT