Skip to content

Instantly share code, notes, and snippets.

@YakDriver
Created February 1, 2018 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YakDriver/b96721d8c3eabd94ea68e8f5abda5120 to your computer and use it in GitHub Desktop.
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
#!/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