Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
#!/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