I've got a text-file that's
sorted by the first field, which is month/day (eg: 02-20)
I've been using
grep on rhe text file, but that's easiest to do with today's date, using the
date command in a script.
I'd like to pull up the prior 3 days, today's date, and the coming 5 days... but I don't know an easy way to handle the end of the month/into the next month. I could, I s'pose, hard code that in? But I was looking for an elegant solution to the problem, so I'm seeking suggestions.
I'd prefer to use regular commands so the script is as portable as possible.
ie: by portable, I mean not just limited to Linux/GNU machines (and/or having to install specific utilities in order to make everything run). Currently I think I'm on a BSD machine, and I've been on most flavors of UNIX (Solaris, blah, blah, blah) - and probably will be in the future.
I'd take something that's more convoluted to program/script, that uses very basic tools, over having to remember to install packages everytime I might be on a different flavor of UNIX (when I could just scp in my scripts directory and have it work).
date -d flag sets daylight savings time :)
-d dst Set the system's value for Daylight Saving Time.
Okay, I just gave an example (as asked) of the type on data in the file (it's much bigger, obvs), but I didn't give edge cases. Here's an edge case, ie: how do I handle the end of month period, without programming in a test for the end of the month, for each month (Or 4 types of month: 30, 31, 28 & 29).
01-01 Something To Do Here Notes that may run for a really long time 02-05 On the 5th of the Month Do this other thing, because of X 02-06 The day after Do this cleanup stuff 03-15 The Ides Remember, remember the Brutus of December 03-29 Edge Does this show up on the 1st of April? 03-30 Edge2 Does this show up on the 1st and 2nd? 03-31 Last day in the month Shows? 04-01 Edge Does this show on 31st? Or does it only show 03-35?