Solved

Grep logs and find max memory usage

Posted on 2011-02-22
3
427 Views
Last Modified: 2013-12-26
Hi,

I have the below log. The last number in each line is my memory usage. I need to grep out this for each line and find the maximum. How do I do this?

2011-02-22T06:45:15.197+0000: 13.952: 19127
2011-02-22T06:51:18.475+0000: 377.230: 771439
2011-02-22T07:47:53.903+0000: 3772.658: 1188357
2011-02-22T08:18:21.294+0000: 5600.049: 1162929
2011-02-22T09:17:24.116+0000: 9142.871: 1152012
2011-02-22T09:41:42.308+0000: 10601.063: 1158554
2011-02-22T10:07:37.928+0000: 12156.683: 1158997
2011-02-22T10:32:53.781+0000: 13672.535: 1165669
2011-02-22T10:57:32.298+0000: 15151.053: 1172145
2011-02-22T11:23:24.918+0000: 16703.673: 1178016
0
Comment
Question by:bowemc
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34950699
awk -F: '{print $NF}' /path/to/logfile | sort -n | tail -1

wmp
0
 

Author Comment

by:bowemc
ID: 34950788
almost perfect. seems to have a whitespace in the front. Can I somehow trim this?
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 34950954
If there is always a whitespace in front of the number in the inputfile you can omit "-F:"

awk '{print $NF}' /path/to/logfile | sort -n | tail -1

If youre not sure you could do

echo $(awk -F: '{print $NF}' /path/to/logfile | sort -n | tail -1)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question