Created
July 31, 2024 12:56
-
-
Save niraami/5fadb004ec9f1b2b760a346a2920b5c3 to your computer and use it in GitHub Desktop.
Get progress of tar extract for use in other commands
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
#!/bin/sh | |
tar_path="file.tar.xz" | |
output_dir="output" | |
# Use pipe viewer to show progress of extraction | |
pv --quiet "${tar_path}" | \ | |
tar --extract --xz --directory "${output_dir}" & | |
# Store ID of the pv process | |
pv_pid=$(pgrep -ox "pv") | |
# Print update every second | |
pv --numeric --interval 1.0 --watchfd $pv_pid:3 2>&1 | \ | |
while read prog; do | |
echo "Installing root filesystem: ${prog}%" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment