Need help with log files and sorting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with log files and sorting
# 1  
Old 05-21-2009
Need help with log files and sorting

Smilie

I have multiple log files from different servers that I need to sort. I used grep to pull out the IP address that I am interested in from all of the logs and dropped those entries into a new file (ipaddr.txt). Now I need to sort those entries into chronological order. I have been playing with awk and sort a bit, but to no avail. I know I have done it in the past, but can't seem to find my notes. Any help is appreciated. I am sure that someone is going to give me a one-liner and I am going to kick myself for even posting this in first place.
# 2  
Old 05-21-2009
What is the format of the dates in your file? Post a portion of the file within code tags.

Regards
# 3  
Old 05-21-2009
Here you go. I have sanitized some info (obviously) but left the date / time intact. Thanks for the help

Code:
2008-01-10 22:30:59 SERVER 192.168.1.1 GET /URL RESOURCE 443 - 192.168.1.2 InetURL/1.0 200 0 0

-B
# 4  
Old 05-21-2009
This seems to work, don't hold me to it though! I strained my eyes making sure it was actually sorting.. but it may not be o.O

Code:
-bash-3.00$ cat set_one
1999-01-14 22:30:00
2007-01-13 22:30:59
2006-01-12 22:30:59
2006-01-11 22:30:59
2008-01-10 22:30:59
2008-01-01 22:30:59
1999-01-11 20:09:08
1999-01-11 20:30:22
1999-08-11 20:02:08
1999-12-11 20:15:08
2008-01-10 22:30:59
2008-01-10 22:30:59
2004-01-09 22:30:59
2000-01-21 22:30:59
2003-01-10 22:30:59
1999-01-13 03:30:01
1999-03-12 06:23:00
1999-02-11 20:30:08
-bash-3.00$ cat set_one | sort -k1n
1999-01-11 20:09:08
1999-01-11 20:30:22
1999-01-13 03:30:01
1999-01-14 22:30:00
1999-02-11 20:30:08
1999-03-12 06:23:00
1999-08-11 20:02:08
1999-12-11 20:15:08
2000-01-21 22:30:59
2003-01-10 22:30:59
2004-01-09 22:30:59
2006-01-11 22:30:59
2006-01-12 22:30:59
2007-01-13 22:30:59
2008-01-01 22:30:59
2008-01-10 22:30:59
2008-01-10 22:30:59
2008-01-10 22:30:59

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Complex data sorting in excel files or text files

Dear all, I have a complex data file shown below,,,,, A_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919 C_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919 A_ABCDEF715 52410.9 18598.2 10611 10754.7 122535 252426 36631.4 C_DBCDI_1353 0... (19 Replies)
Discussion started by: AAWT
19 Replies

2. Shell Programming and Scripting

Sorting files

I have the following set of files and I want to order them according to the ascending values of the run: For example, doing ls -lrt *drw*.log gives n02-z30-sr65-rgdt0p25-dc0p08-4x3drw.log n02-z30-sr65-rgdt0p25-dc0p03-8x6drw.log n02-z30-sr65-rgdt0p25-dc0p01-8x6drw.log ... (18 Replies)
Discussion started by: kristinu
18 Replies

3. Shell Programming and Scripting

i need help in sorting two files

i have file a 123 234 456 567 678 and file b 123|xxx|hhh|ppp or zzz 234|rrr|ttt|xxx 432|ttt|mmm|nnn 678|cft|byt|mop i want to compare file a to file b such that when each of the lines in file a can be found in file b column1 and also xxx or hhh or ppp or zzz can be... (12 Replies)
Discussion started by: blackzinga80
12 Replies

4. UNIX for Dummies Questions & Answers

help with sorting files

find / -type f 2> /dev/null | find -inum +1 2> /dev/null | find -mtime -30 2> /dev/null what i am trying to do i search all regular files in root directory with one or more inodes modified within last 30 days. the /dev/null is to suppress the permission denied outputs. i am now trying to... (5 Replies)
Discussion started by: iluvsushi
5 Replies

5. Shell Programming and Scripting

sorting files

hi i have file like below: col1,col2,col3,col4 val1,val2,val3,val4 abc1,abc2,abc3,abc4 this is a 4 column file with 3 rows. i want to sort the file like.. first on col1, then on col2 and so ..on.. i want the sort order to be descending. Pls help.. Thnks Sumit (2 Replies)
Discussion started by: sumit207
2 Replies

6. UNIX for Dummies Questions & Answers

Need some help for sorting files

I am new to shell scripting can u guys please provide a small script for the following senario step1:need to find some files in a directory for ex having 020908 step2:sort them and redirecting to new file (ex:sort abc > abc.sort) i am trying this but giveing flag error ls -l... (4 Replies)
Discussion started by: cgreddy2020
4 Replies

7. Shell Programming and Scripting

Need help on sorting my log files.

Hi All, Please assist i am newbies in Unix Shell Script. I have 3 different process log files which are content a different status "running" "stopped" and "unknown". I want to bundle up all of 3 processes log, and sort it by status and group it by ProcessNAME, and put it under 1 formatted... (3 Replies)
Discussion started by: anakiar
3 Replies

8. Shell Programming and Scripting

Sorting Files

How to sort such files which contains records of varying length and varying lines? (With respect to Bash shell) Eg: Each record begins with a sting of 1/0(binary) which may or may not be followed by properties like AB,BS etc. I have to sort such records on the basis of 1/0 string and keep the... (2 Replies)
Discussion started by: sandeep_hi
2 Replies

9. Shell Programming and Scripting

Sorting files

Hi, What is the command for sorting files according to their size Thanx in advance (4 Replies)
Discussion started by: sendhil
4 Replies

10. UNIX for Advanced & Expert Users

sorting files

ok so I'm having major issues trying to figure this out: I have this program that I'm inputting the files in hte current directory which are image files...it spits out 5 line chunks describing the files... filename: (name of file) size: (100 x 200) arbitrary data arbitrary data arbitrary... (4 Replies)
Discussion started by: Infraredskies
4 Replies
Login or Register to Ask a Question