Simple countdown on terminal - HCE Engineering S.r.l.
Soluzioni Embedded Industriali

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:

Rodolfo Giometti is an Engineer, IT specialist, embedded GNU/Linux expert and Software Libre evangelist.

During his twenty-year+ experience he worked with GNU/Linux Embedded on x86, ARM, MIPS & PowerPC based platforms.

info
Contattaci per ogni altra informazione.
Facebooktwitterlinkedinmail

Progetto Cosino

Tutti i moduli CPU del Progetto Cosino, le schede carrier e le periferiche sono costruite per ambiente industriale e nascono per aiutare gli sviluppatori a ridurre il time-to-market per tutte le loro idee!

Nuvola dei Tag

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