Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-05-2008, 01:08 PM   #1
LQ Newbie
Registered: Aug 2008
Posts: 3

Rep: Reputation: 0
Need to sort logs by field in the following format "YY Month DD HH:MM:SS"

Another newb question:
I've got a bunch of logs that I want sorted by the timestamp format listed in the subject. I need to merge them then sort them. Any help is appreciated.
Old 08-06-2008, 01:33 AM   #2
Senior Member
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
I would imagine you would want to use (at least in part) the sort command. The problem is that part of your data you are sorting on is separated by spaces and part is separated by colons. However, if the parts of HH:MM:SS are really all two digits (i.e. leading zeroes if needed), then I think the following options will work for you:

sort -t " " -k1,1n -k2,2M -k3,3n -k4,4
Please verify this yourself by consulting the man page and by testing. You can add your input files after the command I've listed or you can pipe an existing stream of data through it. In either case the result is sent to stdout (which can then be piped or redirected). You also might want to check to see if either the -m or -s options are useful to you. (I have no experience with -m.)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LFS6.3 - Ch5.4.1 "/bin/sh sort not found" error at "make bootstrap" ubyt3m3 Linux From Scratch 2 06-23-2008 01:09 AM
Logs filling up with "smbd/service.c:make_connection" - "couldn't find service" DumbTerminal Linux - Networking 14 07-16-2007 07:33 AM
Mplayer woes: "[format] Sample format big-endian AC3 not yet supported" killahsmurf Linux - Software 0 11-26-2006 10:44 AM
how do I use "format" with "pipe" to format decimals Joseph Schiller Programming 1 12-23-2005 01:30 PM
How to get the month in one digit instead of two digits in the "date" command? aadaileh Programming 7 02-05-2004 05:57 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration