Re: sed/awk - columns to rows for a data series
- From: "John W. Krahn" <someone@xxxxxxxxxxx>
- Date: Fri, 11 May 2007 17:12:24 GMT
Banzai wrote:
I have a data series, thus:
========== Tue May 8 00:24:59 BST 2007
ACTIVE SMP 2
ACTIVE SYS 1
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 5
INACTIVE SMP 15
SNIPED JSECURE 14
SNIPED SMP 7
========== Tue May 8 00:30:00 BST 2007
ACTIVE SMP 3
ACTIVE SYS 1
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 7
INACTIVE SMP 11
SNIPED JSECURE 1
SNIPED SMP 7
========== Tue May 8 00:35:00 BST 2007
ACTIVE SMP 2
ACTIVE SYS 2
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 8
INACTIVE SMP 11
SNIPED JSECURE 3
SNIPED SMP 5
Can somebody help me to parse the file so that I have the output like:
00:24:59 2 1 15 1 5 15 14 7
00:30:00 3 1 15 1 7 11 1 7
00:35:00 2 2 15 1 8 11 3 5
Formatting /spacing not important as long as the sense is correct (it can be space
or tab or csv delimitted) - i need to sunsequently import the series into excel.
perl -lne'
BEGIN {
$/ = "=" x 10;
$, = " "; # change to "\t" for tab or "," for comma
}
s/\d+$//m; # remove the year from the date on first line
print /(\d+:\d+:\d+)/, /\d+$/mg;
'
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- References:
- sed/awk - columns to rows for a data series
- From: Banzai
- sed/awk - columns to rows for a data series
- Prev by Date: Re: sort command: default record size
- Next by Date: Re: Ksh output garbled/out-of-sync
- Previous by thread: Re: sed/awk - columns to rows for a data series
- Next by thread: Re: sed/awk - columns to rows for a data series
- Index(es):
Relevant Pages
|