awk - transposing output of program
awk - transposing output of program
(OP)
hello awk gurus;
I have the following problem which I am having difficulties with.
I have a file that is produced on a hourly basis which I would like to friendly format so that it is easier to interpret. Currently, the contents of file is presented on four lines:
header: startdate and time and some other fields
physical-memory: data
virtual-memory: data
footer : enddate and time
Output is colon (:) delimited.
example:
eport-high:header:20211223T010100Z:20211223T020100Z:10:7200
report-high:physical-memory:mem_default:[total]:97124608K:72.36%:-:-
report-high:virtual-memory:vm_default:[total]:102675472K:61.19%:-:-
report-high:footer:20211223T020100Z10:7200
Data is produced in groups of four rows with header and footer containing start and end time. I would like to display each group of four lines as a single line in a new file so it looks like below (comma delimited and transposed):
Startdate,time,Enddate,time,%physicalmemory,physicalmemory,%virtualmemory,virtualmemory;
20211223,T010100Z,20211223,T020100Z10,72.36%,97124608K,61.19%,102675472K;
How do i do this with awk or gawk in solaris ?
Any help appreciated.
Thanks in advance!
dean
I have the following problem which I am having difficulties with.
I have a file that is produced on a hourly basis which I would like to friendly format so that it is easier to interpret. Currently, the contents of file is presented on four lines:
header: startdate and time and some other fields
physical-memory: data
virtual-memory: data
footer : enddate and time
Output is colon (:) delimited.
example:
eport-high:header:20211223T010100Z:20211223T020100Z:10:7200
report-high:physical-memory:mem_default:[total]:97124608K:72.36%:-:-
report-high:virtual-memory:vm_default:[total]:102675472K:61.19%:-:-
report-high:footer:20211223T020100Z10:7200
Data is produced in groups of four rows with header and footer containing start and end time. I would like to display each group of four lines as a single line in a new file so it looks like below (comma delimited and transposed):
Startdate,time,Enddate,time,%physicalmemory,physicalmemory,%virtualmemory,virtualmemory;
20211223,T010100Z,20211223,T020100Z10,72.36%,97124608K,61.19%,102675472K;
How do i do this with awk or gawk in solaris ?
Any help appreciated.
Thanks in advance!
dean
RE: awk - transposing output of program
Something like this should do the work:
dlicheri.awk
CODE
Now when we have your input file
dlicheri.txt
CODE
after running this command
CODE
we get this output file
dlicheri_output.txt
CODE
I don't have Solaris, I tried it on Linux.
RE: awk - transposing output of program
that's great, it works. If i wanted to pipe the output directly to the awk script what would need to change ?
eg:
# collect-stats | dlicheri.awk >> /var/tmp/report-today
RE: awk - transposing output of program
CODE
RE: awk - transposing output of program
or, if you insert on the 1st line of the script the awk shebang, i.e. depending on the location of awk, e.g.
in case of
CODE
CODE
CODE
CODE