At work all the days config files are generated fresh and appended with a session number. The company went public on Feb 16, and the 86400 is seconds in one day. The session number is generated by subtracting the company start day from seconds_since_last_day and adding a few zero's
That is the key to interacting with the days config files. I get this - However I do not understand the
date -ud "$distance days ago 00:00:00".
Is it the number of seconds since 1970?
if $session; then # return the session of the last day seconds_since_day_one=`date -ud "Feb 16 2002" +"%s"` seconds_since_last_day=`date -ud "$distance days ago 00:00:00" +"%s"` days_between=`printf "%010d" $(( (seconds_since_last_day - seconds_since_day_one) / 86400 ))` # Truncate on the left to 9 bytes to leave room # to append the engine suffix for your environment echo $days_between | awk '{l=length($1); print substr( $1, (l-8), l )}'