More late-night Linux
grep -B 3 average stuart.out | grep -v Turnpoint | sed -e 's/cosine/0/g;s/random/1/g;/-/d; s/[[:alpha:][:space:]:]\+/,/g;s/^,8//g; s/,\(([[:digit:]\.]\+)\)//g;s/^,//g' > clean.csv
Yup, I feel that’s quite an impressively long sed argument. It is probably possible to write something more succinct that will have the same effect, but it’d only be even more obfuscated
stuart.out is the data collected from me running myself as a subject for my Part II Psychology project: it’s generated by a C program running on DOS 6.2
. I only need three numbers and a word per condition tested – but the program spews out huge amounts of supplementary text, and isn’t totally regular about where newlines get inserted (I had to forced-close the program a number of times). The greps eliminate incomplete session records, and wipe a handful of unnecessary lines from each blockl; the sed statement gets rid of words in between my precious numbers, and makes the textfile look like a csv.
I’m still working on the sed part of the pipe… it needs a final clause to strip certain, but not all, newlines. I need to match every first and second newline out of three, but not the third, in this file (effectively concatenating three lines together onto one line, and repeating for the next three lines). If anybody can lend any hints, please do – not only is my sed-fu weak, but my google-fu seems to be on the blink as well.
Why am I up late doing this? The gutsy upgrade stalled when my net connection broke inexplicably a few hours ago – and I only noticed recently. Only another hour of downloads to go, then the real fun will begin
That's quite geeky, it has to be 'sed'
Oh, and the gutsy upgrade should be seamless – I did a couple of machines all the way from Edgy to Gutsy the other day – only took about 2hrs and everything worked! (Apart from RAID – if you're using RAID check the changelogs)
That command looks completely incomprehensible, therefore you have my utmost respect.
info sed? I can't imagine it's /that/ complicated to read.
Or you could try awk instead.
Gutsy upgrade failed in one minor respect – compiz-kde wasn't autoinstalled, so I rebooted to find I had no window decorations
That was fairly trivial to fix, however…
[...] SJ Cuthbertson Because Everyone has a blog these days « More late-night Linux [...]
[...] I’ve installed MiKTeX on my XP desktop, and intend to ssh to pip.srcf for certain necessary operations. And now I’m going to get on and try to actually view computers as means again, rather than [...]