# usage: sledge /tmp/foo /tmp/bar 31415 # could also be named crowbar fn sledge () { ifile=$1 ofile=$2 size=$3 if (~ $#* 3) { for (i in `{seq 0 `{ls -l $ifile | awk '{print int($6/'^$size^')}'}}) { echo dd -if $ifile -of $ofile^$i -bs $size -skip $i -count 1 } } }
>> this isn't awk's fault. awk gets the right result. you've illustrated >> the dismalness of seq. > > good point. i should have worked that out! > > it's not the first time i've been caught out by %g - perhaps > the default precision of %g should be 12 or more. at any > rate, seq's default format should be %.12g or better. > > here's a version that works a bit better (also using seq -w so > that you can do "cat $file.*" to reassemble it) > > {for(i in `{seq -w 0 `{ls -l $file | awk '{print int((int($6) - 1) / > '$bs')}'}}) { > dd -bs $bs -count 1 -quiet 1 -of $file.$i } > } < $file