Progress bar for dd

Sunday, Mar 9, 2008

Shameless stolen from Lamby

#!/bin/bash


if [ -d "$1" ]; then

echo "$1" is a directory - aborting.

exit

fi


if [ -d "$2" ]; then

OUTFILE="$2/"`basename "$1"`

else

OUTFILE="$2"

fi


dd if="$1" of="$OUTFILE" &

PID=`pidof -s dd`


while [[ -x "/proc/$PID" ]]; do

kill -USR1 "$PID"

sleep 1

done