LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-05-2008, 12:08 PM   #1
bonz78
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, 12:33 AM   #2
blackhole54
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:

Code:
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.)
 
  


Reply


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 12:09 AM
Logs filling up with "smbd/service.c:make_connection" - "couldn't find service" DumbTerminal Linux - Networking 14 07-16-2007 06:33 AM
Mplayer woes: "[format] Sample format big-endian AC3 not yet supported" killahsmurf Linux - Software 0 11-26-2006 09:44 AM
how do I use "format" with "pipe" to format decimals Joseph Schiller Programming 1 12-23-2005 12:30 PM
How to get the month in one digit instead of two digits in the "date" command? aadaileh Programming 7 02-05-2004 04:57 PM


All times are GMT -5. The time now is 03:20 PM.

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