This is really a note to myself. The other day I needed to figure out what day of the year it was. I was pretty sure that the Unix date command could tell me but I couldn’t remember how to do it and it wasn’t clear from the manual. It turns out the answer is there but not obvious.
The first thing to know is that a starting character of + in the argument tells date that a custom display string is coming. In that string you can use any of the strftime options. One of those is %j for the Julian day of the year. Thus, the answer is simply
date +%j
which for today gives
319