-
-
Save brownman/fa5cf95080a8ea8f36bc to your computer and use it in GitHub Desktop.
dd + progress bar
This file contains hidden or 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
########################################## | |
# ofer shaham (c) | |
# 5-2014 | |
# to: towards more generic usage | |
# from: a forked gist | |
########################################## | |
#dd command + pipe the progress using: pv | |
#depend_package: dd pv | |
########################################## | |
set -o nounset | |
#set -e | |
if [ 1 ];then | |
from_iso=/home/dao04/Downloads/archlinux-2014.05.01-dual.iso | |
to_device=/dev/sdc | |
else | |
#break on un-set string | |
if [ $# -lt 2 ];then | |
#path to *.iso files | |
ls ~/Downloads/*.iso | |
#path to storage devices | |
ls -l /dev/sd[b-z]* | |
echo "supply 2 arguments" | |
echo 1 - the iso file | |
echo 2 - the target storage device | |
exit 1 | |
else | |
from_iso="$1" #path to file.iso | |
to_device="$2" #path to /dev/sdX | |
fi | |
fi | |
#pv calculate relative progress - give it a file size | |
size_iso=`du -sb $from_iso | awk '{print $1}'` | |
#cmd="du -sb $from_iso | awk '{print $1}'" | |
#size_iso=$( eval "$cmd" ) | |
####################### | |
cmd="dd if=$from_iso | pv --eta --size $size_iso --progress --bytes --rate --wait > $to_device" | |
####################### | |
echo "[ press y to continue]" | |
echo "[cmd] $cmd" | |
read answer | |
if [ "$answer" = y ];then | |
echo "[running]" | |
eval "$cmd" | |
else | |
echo "[skipping] " | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment