Created
February 1, 2018 21:46
-
-
Save YakDriver/b96721d8c3eabd94ea68e8f5abda5120 to your computer and use it in GitHub Desktop.
One liner that blocks while it polls for existence of a file while displaying progress based on size of a log file, assuming final size is known
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 | |
# One liner that blocks while it polls for existence of a file while displaying progress based on size of a log file, assuming final size is known | |
# displays "0% done" through "100% done" but never goes over 100% even if log file gets bigger than LOG_DONE_SIZE | |
LOG_DONE_SIZE=57046 | |
while [ ! -f /tmp/SETUP_COMPLETE_SIGNAL ]; do echo "scale=0; $(($(wc -c < /var/log/thefile.log)<$LOG_DONE_SIZE?$(wc -c < /var/log/thefile.log}):$LOG_DONE_SIZE))*100/$LOG_DONE_SIZE" | bc | awk '{printf "%d%% done", $0}' ; sleep 10 ; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment