Bash Display tar progress (without using pv)

Display progress while creating a tar file.

tar czf my_file.tar.gz large_file.bin another_large_file.bin &
# Stop the tar if this script is killed.
trap "kill ${pid}" EXIT
# Display progress while tar is running.
while kill -0 "${pid}" 2> /dev/null; do
    echo -ne " "$(du my_file.tar.gz)"\r";
    sleep 1
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment