Splitting Files in-Place on Linux
Ok, so I have a 160GB disk image I need to split to small pieces (so I
can compress those individually in the background later), but I only
have a few GB free on the disk containing the image. Unfortunately,
split
isn't in place. Here's what I managed to put together using Bash
on Ubuntu:
#!/bin/bash file=$1 size=$2 count=$3
for i in `seq $((count-1)) -1 0` do dd if=$file of=$file.$i bs=4096 skip=$((size*i/4096)) truncate --size=$((size*i)) $file echo $((count-i))/$count done
Admittedly it isn't exactly in place either, but it does only need space for one piece at a time, which was good enough for me.