Create a continuous digital clock in Linux terminal

watch -t -n 1 date +%T
Sample Output
08:10:26

4
By: Nicolargo
2012-09-30 14:10:58

1 Alternatives + Submit Alt

What Others Think

This is cool. I wanted it larger, so I played around with the banner command: watch -t -n 1 "date +%T | xargs banner"
taborj · 371 weeks and 4 days ago
I like doing this too, but it won't work in AIX ("watch" is for caging suspect program behavior, not watching output). I use this instead: while true ; do date +%T ; sleep 1 ; clear ; done or while true ; do date +%T | xargs banner ; sleep 1 ; clear ; done
drockney · 371 weeks and 4 days ago
BORING! Try this instead: watch -tn 1 date +%T \|figlet -c
Mozai · 371 weeks and 3 days ago
Thanks a bunch for this great clock :) Any idea on how to get the timescale down lower- down to the ms or even lower?
isaironi · 67 weeks and 3 days ago
hey i just figured it out : while [ 1 ] ; do echo -en "$(date +%T%N)\r" ; sleep $0.00000000000000000001; done
isaironi · 67 weeks and 3 days ago
oops that's : while [ 1 ] ; do echo -en "$(date +%T%N)\r" ; sleep 0.00000000000000000001; done sorry, I'm kinda new...
isaironi · 67 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: