February 18, 2008
Top-and-tailing log files

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. ;-)

Posted to Linux by Simon Brunning at 12:25 PM
February 15, 2008
Nerd? Me?

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.

Photo 516.jpg

Posted to Apropos of nothing by Simon Brunning at 10:56 AM
February 14, 2008
Who do you have to call a twat to get your comment deleted?

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.

Posted to Funny by Simon Brunning at 05:39 PM
February 11, 2008
Farewell Camden

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. :-(

Posted to London by Simon Brunning at 04:55 PM
New guardian.co.uk site...

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?

Posted to The Internet by Simon Brunning at 04:46 PM
February 06, 2008
Have the Stars Come Right?

Five submarine cables cut now, is it? I wonder if The Bloop is occurring a lot at the moment?

Posted to The Internet by Simon Brunning at 03:57 PM
Joke of the day

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.

Posted to Funny by Simon Brunning at 03:19 PM
February 04, 2008
Bad Science

"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.

Posted to Science and technology by Simon Brunning at 05:36 PM
Spot the Difference

The Guardian

The Oriental Morning Post

FWIF, The Guardian had it first. ;-)

Posted to Website construction by Simon Brunning at 10:55 AM
Bash script of the day
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.

Posted to Funny by Simon Brunning at 10:08 AM
The Secret Diary of Steve Jobs: Monkey Boy's three-legged race

Fake Steve Jobs has really nailed the Microsoft/Yahoo! merger here: Monkey Boy's three-legged race.

Posted to Business by Simon Brunning at 09:49 AM