Created
September 20, 2012 09:16
-
-
Save tabletick/3754852 to your computer and use it in GitHub Desktop.
Copy files with the pipeviewer and show a progressbar
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 | |
# Script for copying files while seeing a progressbar. | |
# Check for pipe-viewer being installed. | |
for tool in pv; do | |
if ! type $tool >/dev/null 2>&1; then | |
echo "ERROR: \"$tool\" not found." | |
echo " This is needed by $scriptname to work. Check your" | |
echo " \$PATH variable or install the tool \"$tool\"." | |
exit 2 | |
fi | |
done | |
# Do the magic. | |
PATHDEST=${!#} | |
if [ ! `echo "$PATHDEST" | grep ".*\/$"` ]; then | |
PATHDEST="${PATHDEST}/" | |
fi | |
for i in "${@:1:$#-1}" | |
do | |
pv -cN "${i}" ${i} > ${PATHDEST}${i} | |
# uncomment this for moving the file | |
# rm "${i}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment