Jonathan Gardner <jgardner@jonathangardner.net> writes:
> Unfortunately, in testing the bugger, it accidentally worked. I find this
> most disturbing. However, I was pleasantly surprised that it failed at
> least one more time before working properly.
Weird; there's no obvious reason for the script to be nondeterministic.
The only idea I can think of is that you were almost out of /tmp space
and the missing data got lost because of lack of space to put it. I'm
not sure whether awk/sed/etc would detect write failures on stdout.
regards, tom lane