display seconds remain with sleep mode unix

hi i just have a quick question how do i display the seconds a sleep coomand stll has before it ontinues?
e.g
sleep 10

echo "you have x seconds before you can continue"
DSwiftieAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TintinConnect With a Mentor Commented:
#!/bin/sh
secs=10

while [ $secs -gt 0 ]
do
     echo "You have $secs seconds before continuing"
     secs=`expr $secs - 1`
    sleep 1
done
0
 
TalmashCommented:
do you want it counting down?
0
 
DSwiftieAuthor Commented:
yep def
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
TalmashCommented:
little change to tintin's:

file = sleep_countdown:
#!/bin/sh
secs=$1

while [ $secs -gt 0 ]
do
     echo "You have $secs seconds before continuing"
     secs=`expr $secs - 1`
    sleep 1
done

chmod 755 sleep_countdown

sleep_countdown 30

you can change the resolution by setting it VIA $2 (set step = $2 ...)

tal
0
 
omarfaridCommented:
Hi,

try this script (call it myscript)

count=$1
while test $count -gt 0
do
echo "time left $count \c"
sleep 1
count=`expr $count - 1`
echo "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
done
echo "\n"

you may use it as

myscript 30
0
 
DSwiftieAuthor Commented:
tin tin's one works thankyou all very much for ur help
0
All Courses

From novice to tech pro — start learning today.