Brian Dessent wrote: > Jan Engelhardt wrote: > > I wanted to get the number of seconds since the start of the day. > > > > echo $[`date +%s` % 86400]; > > How about: > > echo $[$(date +%s) - $(date -d '' +%s)]
That works most of the time and if I were never to run this at midnight I would do just what you suggest here and wouldn't worry about it further. But Jan specifically mentioned wanting midnight. That made me avoid suggesting that case. If this needs to be robust at midnight then it needs one date invocation which needs more work. The problem is that the first date might execute at midnight minus one second. The second date might execute at midnight, which is the next day. If that happens then a negative value would result because the start of the day subtracted off would be the start of the next day. Therefore the need to get the time once only. Bob _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils