-
-
Save anonymous/2416431 to your computer and use it in GitHub Desktop.
DD wrapper around dd with progress output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# DD is a wrapper around dd with progress output. | |
# | |
# version: VERY BETA :-) | |
_verbose() | |
{ | |
echo $1 | |
} | |
_kill_dd() | |
{ | |
echo "dd ($ddpid) is still running, killing..."; | |
kill $ddpid | |
} | |
on_die() | |
{ | |
echo "killing dd ($ddpid)" | |
ps $ddpid && _kill_dd | |
ps $ddpid || exit 1 | |
} | |
trap 'on_die' TERM | |
trap 'on_die' INT | |
dd $@ & | |
ddpid=$! | |
_verbose "dd has pid $ddpid" | |
while [ 1 ]; | |
do | |
sudo kill -USR1 $ddpid 2>/dev/null || exit 0; | |
sleep 1; | |
done | |
ps $ddpid && _kill_dd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment