Solved

Grep logs and find max memory usage

Posted on 2011-02-22
3
428 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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…

830 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