Simple countdown on terminal - HCE Engineering S.r.l.
Embedded GNU/Linux solutions

Simple countdown on terminal

In these days I needed a really simple countdown application and, instead of doing a graphical program, I decided to use Bash and some ASCII-art!

The script

First of all we need a Bash script simulating the countdown. We can do it in multiple ways and below is a possible solution:

The script’s structure is simple and we can see how it works by simply executing it as below:

Now we can enlarge time’s characters by using figlet  utility. This tool reads from stdin (or on the command line) a string and reproduces it on stdout using ASCII-art as below:

The option argument  -f big  it’s used to select larger fonts than the default.

For our purposes we can send the printf ‘s output to figlet and the trick is done!

The result

Below is a screenshot of my terminal where I enlarged my terminal’s font is such a way the time is displayed as a real digital clock.

Below is the complete code of clock.sh  script:

info
Contact us for further information.
Facebooktwitterlinkedinmail

Cosino Project

All the Cosino Project's CPU modules, carrier boards and peripherals are build for industrial environment and they are born to help developers in reducing time-to-market for all their ideas!

Tags Cloud

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close