Programming Tutorials

Digital Clock in Shell Script

By: Vivek G in Linux Tutorials on 2011-01-29  

This shell script shows how to display a digital clock in linux.
echo "Digital Clock for Linux"
echo "To stop this clock use command kill pid, see above for pid"
echo "Press a key to continue. . ."

while :
    ti=`date +"%r"`      
    echo -e -n "\033[7s"    #save current screen postion & attributes
    # Show the clock
    tput cup 0 69          # row 0 and column 69 is used to show clock
    echo -n $ti            # put clock on screen
    echo -e -n "\033[8u"   #restore current screen postion & attributs
    #Delay fro 1 second
    sleep 1

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)