Parsing a large log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing a large log
# 15  
Old 06-03-2008
Another thing: do you have very limited memory and/or hard disk space? Grepping a file that size should not be a problem on even relatively modest hardware.

Code:
vnix$ dd if=/dev/urandom of=/tmp/randomfile bs=65536 count=65536
^C  # interrupted when I got bored
23196+2 records in
23196+1 records out
1520214016 bytes (1.5 GB) copied, 317.015 s, 4.8 MB/s

vnix$ time grep '^06/01/' /tmp/randomfile 

real    0m51.461s
user    0m1.940s
sys     0m1.768s

This is a basic PATA disk which should be easy to beat if you have SCSI or SATA.

Last edited by era; 06-03-2008 at 09:59 AM..
# 16  
Old 06-03-2008
Quote:
I'm sorry, no offense, but I cannot type this any slower than this: ...
Smilie

@asth
If it times out, you have another problem - does it time out with an error or just come back to the prompt or do you have to do ctrl+c or something after some minutes of boredom?
It doubt the tools you are using are the problem. Looks like you got a performance issue - something blocking the resources (disks, cpu, memory, whatever).

300-400MB of log is nothing if you simply parse it without layered loops and such stuff, which all examples posted did not - they were not complex.
# 17  
Old 06-03-2008
If i use tail command then does'nt take much time and i get the required output.
I have space issue thats why it is taking time.
But i have to work on these sites only so need to find out a way to divide the file in chunks and then find out the chunk of last 24 hours say.

Thanks
# 18  
Old 06-03-2008
If you cannot read the file from the beginning, there is no way really to know. But based on experimentation you can probably find a value for tail which is likely to cover more than the last 24 hours by a good margin.

Sounds like you ought to be running some sort of rotation script in your nightly cron job to force the log file into smaller chunks. Which platform are you on? Does the application which generates this log support log rotation?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a subset of data from a large matrix

I do have a large matrix of the following format and it is tab delimited ch-ab1-20 ch-bb2-23 ch-ab1-34 ch-ab1-24 er-cc1-45 bv-cc1-78 ch-ab1-20 0 2 3 4 5 6 ch-bb2-23 3 0 5 ... (6 Replies)
Discussion started by: Kanja
6 Replies

2. Shell Programming and Scripting

Parsing large files in Solaris 11

I have a 1.2G file that contains no newline characters. This is essentially a log file with each entry being exactly 78bits long. The basic format is /DATE/USER/MISC/. The single uniform thing about the file is that that the 8 character is always ":" I worked with smaller files of the same... (8 Replies)
Discussion started by: os2mac
8 Replies

3. Shell Programming and Scripting

Log parsing

I have a directory with daily logs that have records like this: Date: 04/17/13 Time: 09:29:15 IP: 123.123.123.123 URL: usr/local/file1 and I want to only count how many times each file was accessed (e.g. file1 in that example above), and I want to also look in all the logs in the current... (3 Replies)
Discussion started by: Jaymz
3 Replies

4. UNIX for Dummies Questions & Answers

I need to isolate a date in a large log file

I wrote head -n1 example.log I grab the first line of the log, but I need to isolate just the date, which is 08/May/2012:09:52:52. I also need to find the reverse of this, which would be tail... http://i.imgur.com/Lp1eBD0.png Thanks in advance (4 Replies)
Discussion started by: spookydll
4 Replies

5. Shell Programming and Scripting

Help needed for parsing large XML with awk.

My XML structure looks like: <?xml version="1.0" encoding="UTF-8"?> <SearchRepository> <SearchItems> <SearchItem> ... </SearchItem> <SearchItem> ... ... (1 Reply)
Discussion started by: jasonjustice
1 Replies

6. Red Hat

Help for capturing a URL from a line from large log file

Can someone please help me how do I find a URL from lines of log file and write all the output to a new file? For e.g - Log file has similar entries, 39.155.67.5 - - "GET /abc/login?service=http://161.120.36.39/CORPHR/TMA2007/default.asp HTTP/1.1" 401 3218 54.155.63.9 - - "GET... (2 Replies)
Discussion started by: rockf1bull
2 Replies

7. Shell Programming and Scripting

parsing large CDR XML file

Dear Freind in the file attached how parse the data to be like a normal table :D (3 Replies)
Discussion started by: saifsafaa
3 Replies

8. Shell Programming and Scripting

Cutting a large log file in to smaller ones

I have a very large (150 megs) IRC log file from 2000-2001 which I want to cut down to individual daily log files. I have a very basic knowledge of the cat, sed and grep commands. The log file is time stamped and each day in the large log file begins with a "Session Start" string like so: ... (11 Replies)
Discussion started by: MrTangent
11 Replies

9. Shell Programming and Scripting

Problem with parsing a large file

Hi All, Following is the sample file and following is the op desired that is the last entry of each unique first field is required. My solution is as follows However the original file has around a million entries and around a 100,000 uniques first fields, so this soln.... (6 Replies)
Discussion started by: gauravgoel
6 Replies

10. UNIX for Dummies Questions & Answers

Splitting a large log file

Okay, absolute newbie here... I'm on a Mac trying to split an almost 2 Gig log file on a Unix box into manageable chunks for my web-based log analysis tool. What do I need to do, what programs do I need to do it? All and any help appreciated/needed :-) Cheers (8 Replies)
Discussion started by: simmonet
8 Replies
Login or Register to Ask a Question