Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LANG='C'
- BLOCK_SIZE=512
- SPARE_SIZE=16
- IN_FILE=file.in
- OUT_FILE=file.out
- rm -f $OUT_FILE
- # Read per block+spare and write block, skipping spare part
- i=0
- while [ -z "`dd if=$IN_FILE of=block.file bs=$((BLOCK_SIZE + SPARE_SIZE)) count=1 skip=$i 2> \
- >(grep 'cannot skip to specified offset')`" ]; do
- echo "Processing $i block at $(((BLOCK_SIZE + SPARE_SIZE) * i)) offset..."
- dd if=block.file bs=$BLOCK_SIZE count=1 status=none >> $OUT_FILE
- ((i++))
- done
- rm block.file
Advertisement
Add Comment
Please, Sign In to add comment