Home » Home » HOW TO: Display a Digital Clock In Terminal?

Think a better world in the absence of clock, where everyone runs their chance of leaving the work undone on time. But this fails if it comes to Linux user. Linux is a intelligent OS species, which could print a continuous Date/Time in terminal so users have their smart way.


To display date and time in terminal there is a default command in Linux,


Which gives the output of current day,month,date,time, timezone and year.

The ‘date’ command includes in printing the time as well, to retrieve time from date command,

$date +%r


$date +%T

Which display only the time.

If you want to print a continuous output of time, means digital clock to print in terminal, you can execute the following code.

$watch -n 1 date +%r

Suppose if you want to have a clear display of time in terminal, you can echo the output of $date command and fixing it in a infinite loop which will update and display every second also appears to resemble continuous Digital Clock in Terminal.

This could be done by passing either of command in Terminal

$clear; while true ; do echo -e `date +%T` ; sleep 1; done

$while [ 1 ] ; do echo -en "$(date +%T)r" ; sleep 1; done

As the code implies, I have done the same in little script.

Hope you enjoyed the article, please feel free to leave your comments… :)

Leave a Reply

Your email address will not be published. Required fields are marked *