Skip to content

Instantly share code, notes, and snippets.

@moritzmhmk
Last active September 25, 2015 17:29
Show Gist options
  • Save moritzmhmk/5ca136d5295003b4a7c8 to your computer and use it in GitHub Desktop.
Save moritzmhmk/5ca136d5295003b4a7c8 to your computer and use it in GitHub Desktop.
improved dd with percentage
#!/bin/bash
in="$1"
out="$2"
if [[ $# -ne 2 ]] ; then
echo "Usage: $0 <input> <output>"
exit
fi
if [ "$(uname)" == "Darwin" ]; then
size=`stat -f "%z" $in`
dd if="$in" bs=4m | pv -s $size | dd of="$out" bs=4m
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
size=`stat -c %s "$in"`
dd if="$in" bs=4M | pv -s $size | dd of="$out" bs=4M
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment