timer script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Attached is a bash script that counts down by seconds and display the
remaining time on a single line of output. The single argument is the
number of seconds you wish to wait. Remaining time below ten seconds
will be given on each second, below 100 seconds will be given every ten
seconds, and longer waits will be given every 100 seconds.

I am not sure I like it, but it works. Unfortunately it prevents you
from using other arguments than seconds. i.e., not minutes or hours.

HTH
Chuck


-- 
The Moon is Full
"Things are in the saddle, and they ride mankind." Ralph Waldo Emerson
Personal site www.hhs48.com, Software site www.mhcable.com/~chuckh
-------------- next part --------------
#!/bin/bash
if [ "$1" != "" ] && [ "$1" != "0" ]; then
x=$1
echo -n "Waiting"
x1=$((x/10))
if [ "$x" != "$((x1*10))" ] && [ "$x1" != "0" ]; then
echo -n " $x"
fi
until [ "$((x/10))" = "0" ]; do
x1=$((x/10))
x2=$((x/100))
if [ "$x" = "$((x2*100))" ] && [ "$((x2/10))" = "0" ]; then
echo -n " $x"
else
if [ "$x" = "$((x1*10))" ] && [ "$((x1/10))" = "0" ]; then
echo -n " $x"
fi
fi
sleep 1
x=$((x-1))
done
until [ "$x" = "0" ]; do
echo -n " $x"
sleep 1
x=$((x-1))
done
echo " GO!"
fi


[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux