You're right, there should be a space there; I'll correct my original post.
However changing the shebang to /bin/bash
should not be necessary, as /bin/sh
should always point to a POSIX compliant shell interpreter. (I believe Debian-based OSes use dash
as their primary shell and sh
, which has some issues with POSIX compliance.)
If you really want to ensure bash
as your interpreter, your shebang should really be:
#!/usr/bin/env bash
(I know in today's world of zsh
, fish
, and others, that strict Unix/POSIX compliance and portability is difficult to comprehend; but having a single script that works everywhere still should have some importance.)
I should also note, that my original post was with GNU date
, most commonly found on Linux OSes. BSD date
is quite different, and needs different parameters. The script could be made to check for the difference, but I presently don't have the motivation (and my BSD date
modifications have been posted elsewhere on this forum already). (For those curious, OSes using BSD userlands include TrueNAS Core (and its earlier incarnations FreeNAS), FreeBSD, and macOS, among others.)