Some of our log files are huge - I have a 10 GB file on my HDD right now. These files are unwieldy to say the least, and you usually have a good idea as to the time in which a particular problem occurred, so it's often handy to be able to chop out a specified time range. I keep forgetting how to do this, and re-inventing the process. So, here for my own benefit at a couple of methods.
The hard way
From the bash shell:
wc -l your.log
This will count the lines in your file.
grep -n 12:00: your.log | head -n 1
This will give you the line number of the 1st line containing "12:00:" - in this example, I want log entries starting at midday, so this is the first line that I want.
grep -n 12:10: your.log | tail -n 1
This will give you the line number of the 1st line containing "12:10:" - in this example, I want log entries up to ten past twelve, so this is the last line that I want.
tail -n $[total-first] your.log | head -n $[total-last] > your_focused.log
Replace first, last and total with the values you got above, and you'll end up with a file containing only the time range that you wanted. (If you only want to look at the file once, you can just pipe into less or whatever rather than piping into an output file.)
The easy way
python -c "import itertools, sys; sys.stdout.writelines(itertools.takewhile(lambda item: not '12:10:' in item, itertools.dropwhile(lambda item: not '12:00:' in item, open('your.log'))))" > your_focused.log
Same thing, only this will read through the file just once.
Now, I'm fully expecting someone to come and tell me the real easy way. ;-)
I somehow contrived to break my glasses on my way into work this morning. They are currently held together with sellotape. Even by my standards, I'm a bit of a nerd cliche today.
So, naturally, it's this morning that I meet the lovely Nell Boase. Sigh.
Update: Photo as requested.
Via Rosie, Max, 19 is the funniest thing I've read in ages.
Of course, he's nineteen, so of course he's a tosser. Had this been up on facebook, it would blend in perfectly. It's just on the Grauniad travel front that he's going to attract such opprobrium.
First, half of it is earmarked for redevelopment, then the other half goes up in smoke.
Of course, they say they'll rebuild, but it'll never be the same. :-(
It's been a busy weekend, but it's mostly done now. We did UK, World, The Guardian, The Observer and Audio this time, along with a few bits and pieces. The biggies.
Next up for re-launch, Sport. And given the storm-in-a-teacup over the removal of the football link from the front page, and you imagine what it'll be like when the entire sport site changes?
Five submarine cables cut now, is it? I wonder if The Bloop is occurring a lot at the moment?
Eric: Who was that lady I seen you with last night?
Ernie: You mean, ‘I saw’.
Eric: Sorry. Who was that eyesore I seen you with last night?
Thank you, Morecambe and Wise.
"An Italian urologist and self-professed lover of the sexy shoe set out to prove that high heels were not as bad for women's health as some suggest." Emphasis mine. Ben Goldacre must be rubbing his hands with glee.
FWIF, The Guardian had it first. ;-)
yes bum | xargs banner -w 50
We had two of these running on Friday, in two vertically windowed terminals, with the 2nd window showing "poo". That's a Turner Prize right there, that is.
Fake Steve Jobs has really nailed the Microsoft/Yahoo! merger here: Monkey Boy's three-legged race.