Command to know the days until the end of the year

Although we are not on the end of the year, much less, I find this tip particularly interesting.

In a terminal let's just put this:

echo "Faltan $(($(date +%j -d"Dec 31")-$(date +%-j))) días para que termine el año $(date +%Y)."

As you can see, something like:

There are 215 days until the end of 2013.

The operation is simple, we are using the command and variable date , with date +%j we know the day of the year we are in ( yesterday May 30th is day number 150 ), then we find out how many days the year has -d»Dec 31″ ( … or that's what I understood ), to finally subtract those days that the year has from the number of the current day, this will give us how many days are left.

Well, with the date command you can do a lot more things than I thought 

regards


Add as preferred source in Google