Skip to content

Instantly share code, notes, and snippets.

@tabletick
Created September 20, 2012 09:16
Show Gist options
  • Save tabletick/3754852 to your computer and use it in GitHub Desktop.
Save tabletick/3754852 to your computer and use it in GitHub Desktop.
Copy files with the pipeviewer and show a progressbar
#!/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