Solved

display seconds remain with sleep mode unix

Posted on 2007-11-18
6
321 Views
Last Modified: 2011-10-03
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"
0
Comment
Question by:DSwiftie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:Talmash
ID: 20307730
do you want it counting down?
0
 

Author Comment

by:DSwiftie
ID: 20308143
yep def
0
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 20308567
#!/bin/sh
secs=10

while [ $secs -gt 0 ]
do
     echo "You have $secs seconds before continuing"
     secs=`expr $secs - 1`
    sleep 1
done
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:Talmash
ID: 20312042
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 20312395
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
 

Author Comment

by:DSwiftie
ID: 20316128
tin tin's one works thankyou all very much for ur help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question