Solved

Grep logs and find max memory usage

Posted on 2011-02-22
3
426 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
Comment Utility
awk -F: '{print $NF}' /path/to/logfile | sort -n | tail -1

wmp
0
 

Author Comment

by:bowemc
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now