Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Grep logs and find max memory usage

Posted on 2011-02-22
3
Medium Priority
?
434 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

715 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