2 ms·
It looks like date allows the + option. For example, date +'%Y-%m-%d-%H-%M-%S'
by asimjalis 6y ago
It looks like date allows the + option. For example,
date +'%Y-%m-%d-%H-%M-%S'
- theamk 6y agothat's not the kind of option the article is talking about -- the long options are generally english words, and there is a limited set of them. Date uses two dashes for them -- like "--utc" and "--set". They won't work with + Your example is a format string. date needed to tell if the positional argument is a format or a new date, and to make it easy, they decided to prefix the format with a special character. I am going to guess that this character should not be - (to avoid confusion with options), or numeric (to avoid confusion with new date), not have special meaning in common shells (to keep quoting simpler). They could have chosen : or ^ for example.
- throw7 6y agoNah. date could have used -f or any other letter to specify the format string. They did not _have_ to use +.
- theamk 6y agoCompletely agree, the implementer of date had many options. choosing + character, they apparently went for conciseness instead of convention. Not sure what you are disagreeing with though, I made no claims that someone had to use +, or positional argument in general. Just an observation about what might have guided the design process.
- JonathonW 6y agoThe + prefix for the format passed to date is mandated by POSIX-- to distinguish the date format from other arguments.
- deleted 6y ago[deleted]