On 8 May 2010 18:35, Russ Cox <[email protected]> wrote:
> bs=1474560
> cat $file | for(i in `{seq 0 `{ls -l $file | awk '{print
> int($6)/'$bs'}'}}) { dd -bs $bs -count 1 -of $file.$i }
that looks very plausible, but it doesn't actually work,
as awk doesn't coelesce short reads (it gets short
reads from the pipe)
this works a little better:
bs=1474560
{for(i in `{seq 0 `{ls -l $file | awk '{print
int($6)/'$bs'}'}}) { dd -bs $bs -count 1 -of $file.$i -quiet 1 }} < $file
but there's still a little annoyance - if the file size is an exact
multiple of the block size, it will generate an unnecessary zero-length
file at the end.
i tried to fix it to get rid of this, but ran hard up against awk's
dismalness. to illustrate:
% seq 106908504 106908509 | awk '{print $1 % 4}'
0
0
0
0
0
0
%
oh dear.