Solved

Grep logs and find max memory usage

Posted on 2011-02-22
3
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to run my script during boot in rhel 7 14 792
IE 11 + long running scripts 3 124
UNIX Script. Send email if failure 8 93
Linux: using  awk and print inside cURL 4 49
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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

752 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