From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <4be4dd37.NDxcevbsQ+CfYFvN%yard-ape@telus.net> <104169d77ce3a909d635845ac86efc30@9netics.com> Date: Mon, 10 May 2010 08:57:55 +0100 Message-ID: From: roger peppe To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] Binary File split Topicbox-Message-UUID: 1e8f70bc-ead6-11e9-9d60-3106f5b1d025 On 8 May 2010 18:35, Russ Cox 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.