All these years I was using *all dirty shell script hacks* to create my own date manipulation utilities for backups and other admin task. Thanks to this project no more dirty work.
Recently our site visitor Milton left a comment about this nice utility. This utility is very good if you would like to do lots of date manipulation or to crate report/log file names with date in filename.
From the project home page:
yest is a command line date/time manipulation and formatting program, very useful in scripts. You can easily add or subtract days, hours and/or minutes from a specified date. It supports all date command output formats plus more.
This program is called “yest” because the default is to output yesterday’s date. This utility knows about leap year, aylight savings time, and such variations.
Task: Install yest
Download yest from project home page. Or use wget command as follows:
$ cd /tmp
$ wget http://easynews.dl.sourceforge.net/sourceforge/yest/yest-188.8.131.52.tgz
Untar the source code:
$ tar -zxvf yest-184.108.40.206.tgz
Compile and install binary
$ su -
# gcc -o /usr/bin/yest yest-220.127.116.11.c
Install man page:
# cp yest-18.104.22.168.man1 yest.1
# gzip yest.1
# cp yest.1.gz /usr/share/man/man1/
How do I use yest?
Following command will display yesterdays date (default):
Thu Oct 12 23:45:24 IST 2006
Display the date ten days ago (-10 or +10 next 10 days)
Thu Oct 12 23:46:23 IST 2006
$ yest -10
$ yest +10
Format date in dd-mm-yyyy:
$ yest -10 "%d-%m-%Y"
Get more help
$ yest --help
$ man yest
yest in action
So to executing a script/command on the last day of a month, I was using following script:
TOM=$(TZ=MST-24 date +%d)
if [ $TOM -eq 1 ]; then
# commands or script on the last day of a month
But with yest it is just one line shell script :D
[ $(yest +0 "%d") -eq $(yest "%L") ] && /path/to/mytask || :
=> yest Download is highly recommended tool for all seasoned UNIX admin.Share this on: