Progress bar for dd

Published: Sunday, Mar 9, 2008 Last modified: Thursday, Nov 14, 2024

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