Working with calendars in the shell

Command-line aficionados do not have to forgo calendars and appointment reminders. The shell offers many tools for user-friendly handling of date definitions in scripts.

Working with dates in the shell often causes problems. Aside from the usual typos, this is usually due to mismatched language and country settings. In practice, you will especially be confronted with this when working with databases.

Manual input can be relatively easily checked for formal correctness. The simplest aspect to change is the separators or the order of day, month, and year. An example of this is shown in Listing 1, and the corresponding output is shown in Figure 1. The short script supports both correct input with the dot as a separator and input with the comma in the numeric keypad for quick data entry.

dialog and YAD

If you attach importance to user-friendliness as well as correct date values, why not use the attractive (semi-)graphical input options offered by dialog or YAD?


Use Express-Checkout link below to read the full article (PDF).

Posted by Contributor