November 30th, 2004


userinfo senji
2004/11/30 16:43:00 - Stuff what I have done today.
I'm feeling quite chuffed about thinking at right angles to problems today; having achieved a few tasks in deceptively simple ways.

For example; to find every occurance of a bitstring in a binary file (I was looking for ÿÿÿÿ):
sed 's/ÿÿÿÿ/-ÿÿÿ/g' <file.orig >file.evil
cmp -bl file.{evil,orig} | sed 's/ 55.*//'


And a simple function for doing things multiple times:
times ()
{
__times_repeats=$1;
shift;
for __times_loopv in $(seq 1 $__times_repeats);
do
$@;
done;
unset __times_loopv;
unset __times_repeats
}

(I expect that there are probably obvious bugs in that!)
Current Mood: [mood icon] accomplished
Entry Tags: geeky, shell hacks, work

< | 4 glosses | comment | > )

userinfo ewx
[userpic]
2004/11/30 09:51:18

I think it should be "$@", and am not sure if there's a good reason why you're not using local variables.

Confused about the second sed, I can't see why it shouldn't be 45 instead of 55. Are you in a non-ASCII universe or something?


reply | thread )
userinfo senji
[userpic]
2004/11/30 11:08:31
I was wondering if it should be "$@" on the bus on the way home, but didn't manage to convince myself either way.

cmp(1) outputs in octal.
reply | parent | thread )
userinfo ewx
[userpic]
2004/11/30 14:51:02

octal: doh!

The quotes are necessary; otherwise you break the usual adverbial property:

lyonesse$ f() { $@; }
lyonesse$ f 'echo 1     2'
1 2

reply | parent | thread )
userinfo senji
2004/11/30 15:04:52
You're quite right.

reply | parent | thread )

< | 4 glosses | comment | > )

Stuff what I have done today. - Squaring the circle...

> log in
> recent entries
> fiends
> archive
> toothywiki page
> profile
> new entry
> recent comments


> go to top