1753894 Members
7497 Online
108809 Solutions
New Discussion юеВ

Re: Script needed

 
SOLVED
Go to solution
vinayan
Advisor

Script needed

Hi Everybody,

Below pasted is the report generated via MWA export. Now What I need is a script which will grep only the columns in Hour basis ,lets say 00.00 , 01.00 , 02.00

Replies will be highly appreciated with points.


"MWA Export 10/08/08 10:19 AM Logfile: /var/opt/perf/datafiles/ SCOPE/UX C.03.71.00 batebsd1"
" "|" "|" "|" Peak "|"Memory"|" "|
" Date "|"Time "|"CPU % "|"Disk %"|" % "|"Swap %"|
"09/08/08"|"00:00"| 28.57|100.00| 79.62| 44.00|
"09/08/08"|"00:05"| 39.39| 91.85| 79.85| 44.00|
"09/08/08"|"00:10"| 11.48|100.00| 79.87| 44.00|
"09/08/08"|"00:15"| 7.71|100.00| 80.36| 45.00|
"09/08/08"|"00:20"| 8.25|100.00| 80.35| 45.00|
"09/08/08"|"00:25"| 8.44|100.00| 81.76| 46.00|
"09/08/08"|"00:30"| 7.64|100.00| 80.91| 45.00|
"09/08/08"|"00:35"| 8.43|100.00| 81.34| 45.00|
"09/08/08"|"00:40"| 11.69|100.00| 81.37| 45.00|
"09/08/08"|"00:45"| 18.02| 87.10| 81.33| 45.00|
"09/08/08"|"00:50"| 28.56| 69.90| 82.37| 46.00|
"09/08/08"|"00:55"| 19.33| 71.11| 81.35| 45.00|
"09/08/08"|"01:00"| 19.16| 65.81| 81.31| 45.00|
"09/08/08"|"01:05"| 17.46| 66.03| 81.31| 45.00|
"09/08/08"|"01:10"| 16.99| 68.01| 81.31| 45.00|
"09/08/08"|"01:15"| 16.92| 69.28| 81.31| 45.00|
"09/08/08"|"01:20"| 17.41| 70.75| 81.31| 45.00|
"09/08/08"|"01:25"| 16.43| 74.13| 81.31| 45.00|
"09/08/08"|"01:30"| 12.91| 80.88| 78.78| 44.00|
"09/08/08"|"01:35"| 6.68| 78.69| 78.66| 44.00|
"09/08/08"|"01:40"| 6.84| 67.62| 78.66| 44.00|
"09/08/08"|"01:45"| 6.61| 31.24| 74.96| 42.00|
"09/08/08"|"01:50"| 0.83| 1.10| 74.96| 42.00|
"09/08/08"|"01:55"| 0.87| 0.71| 74.96| 42.00|
"09/08/08"|"02:00"| 0.86| 0.87| 74.96| 42.00|

Rgds
Vinayan
8 REPLIES 8
Ivan Krastev
Honored Contributor

Re: Script needed

Grep for value ":00":


grep ":00" filename

regards,
ivan
Hein van den Heuvel
Honored Contributor

Re: Script needed

Please explain why you did not think that was a perfect solution for in inperfect question?!

Inperfect because you wrote 00.00 as hour and probably meant 00:00, and in " grep only the columns in Hour " the 'grep' is not an English verb best I know, but you possibly meant 'extract using the tool grep' there by severely limiting the range of possile solution. And the columns in Hour is really column #2, but you probably meant the worst with a whole hour in column #2.

awk '/:00/ || NR < 4' your-file

grins,
Hein.

Hein van den Heuvel
Honored Contributor

Re: Script needed

That was an iMperfect reply I wrote there :^)
Hein.
OFC_EDM
Respected Contributor

Re: Script needed

Did you mean to grep every hour of the day?

grep "[0-9][0-9]:00" filename

This should get the records for

00:00
01:00
02:00
down to
23:00

Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor
Solution

Re: Script needed

using your data here's the output

grep "[0-9][0-9]:00" test.txt
"09/08/08"|"00:00"| 28.57|100.00| 79.62| 44.00|
"09/08/08"|"01:00"| 19.16| 65.81| 81.31| 45.00|
"09/08/08"|"02:00"| 0.86| 0.87| 74.96| 42.00|
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Script needed

I'm having a slow day.

Here's an expanded line to make it Excel CSV compatible:

grep "[0-9][0-9]:00" test.txt | awk -F\| '{print $1","$2","$3","$4","$5","$6}' > somefile.csv

Output looks like:
"09/08/08","00:00", 28.57,100.00, 79.62, 44.00
"09/08/08","01:00", 19.16, 65.81, 81.31, 45.00
"09/08/08","02:00", 0.86, 0.87, 74.96, 42.00


If you want to get rid of the double quotes too (really slow day)

grep "[0-9][0-9]:00" test.txt | awk -F\| '{print $1","$2","$3","$4","$5","$6}' | sed -e 's/"//g' >> somefilename.csv
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Script needed

If you have MWA there's a command with a report option to do this automatically I believe.

But you'll have to dig through any manuals you can find to discover the command. Been a few years since I did that.

Cheers
The Devil is in the detail.
vinayan
Advisor

Re: Script needed

Thank u very much