Skip to content

Instantly share code, notes, and snippets.

@vasi
Created June 2, 2014 01:23
Show Gist options
  • Save vasi/91aa91634c6eb45c0963 to your computer and use it in GitHub Desktop.
Save vasi/91aa91634c6eb45c0963 to your computer and use it in GitHub Desktop.
Create a tarball, using a progress bar
#!/usr/bin/env bash
# First arg is always option
arg1="$1"
shift
# Find first non-option
for i in "$@"; do
if [[ -z "$dir" && "$i" != -* ]]; then
dir="$i"
fi
done
size=$(du -sk "$dir" | cut -f1)
tar "$arg1" "$@" | pv -barpets "${size}k"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment