Skip to content

Instantly share code, notes, and snippets.

@CDRO
Created September 9, 2017 12:18
Show Gist options
  • Save CDRO/9524efd1a1605988ca84724c23c400fb to your computer and use it in GitHub Desktop.
Save CDRO/9524efd1a1605988ca84724c23c400fb to your computer and use it in GitHub Desktop.

This is an easy script that lets you countdown after having checked the size of a folder.

I used this to monitor the state of a file transfer with lots of small file and no proper progress bar.

Credit for the counter go to dsmsk80(https://serverfault.com/questions/532559/bash-script-count-down-5-minutes-display-on-single-line#answer-532564)

Inline version (replace interval)

interval=30; while true; do clear; echo du -hs `pwd`/\*; du -hs * ;  secs=$interval; while [ $secs -gt 0 ]; do echo -ne "Refresh in $secs seconds\033[0K\r"; sleep 1; : $((secs--)); done; done

As a bash script

#!/bin/bash
 
interval=0
if [ -z $1 ];
then
  interval=30
else
  interval=$1
fi
while true; do
  clear
  echo du -hs `pwd`/*
  secs=$interval
  while [ $secs -gt 0 ]; do
    echo -ne "Refresh in $secs seconds\033[0K\r"
    sleep 1
    : $((secs--))
  done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment