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 data, with date +% j we know the day of the year we areyesterday may 30 is day 150), then we get how many days the year has -d »Dec 31 ″ (... or so 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.
Anyway, with the date command you can do a lot more things than I thought 😀
regards
That's good!
It is also used for many other things, not just to wait for the end of the year parties .. It could be to remember the anniversary with our partner, etc.
Those codes above, do they belong to some programming language?
Bash
It's good
Very good, and by modifying the month and the day I can calculate other dates 🙂
"Cal -j"
o
«Cal -j 2013»
It shows you the day of the year. That is to say, today at this time is the 151st day of the year, although there is little left to finish ...
It's good to combine it with something like with notify-send:
notify-send «DesdeLinux It's the Best :)» «There are $(($(date +%j -d»Dec 31″)-$(date +%-j))) days left until the end of the year $(date +%Y).»
Ask just out of curiosity: can comments be formatted with a tag, such as bold or colors?
You could also use an alias to not write everything every time you want to know how many days are left:
alias days = 'echo "Missing $ (($ (date +% j -d» Dec 31 ") - $ (date +% - j))) days until the end of the year $ (date +% Y)."'
It is interesting to do it in the console, but if you do it in exel and save that file every time you open it, it will give you the data of how many days are left for whatever you want.
Very useful, thanks!
Very useful ... Adaptable to any countdown indeed. 😛