Re: Silly little regex question
Roberto C. Sanchez wrote:
> Adam Aube wrote:
>> Eric d'Alibut wrote:
>>>In a shell script:
>>>`eval date +%j`
>>>
>>>returns the so-called "Julian" date (a misnomer I believe, but there
>>>it is), the number of days into the present year, aka "yearday":
>>>
>>>$ echo `eval date +%j`
>>>036
>>>
>>>I want a regex that will strip the leading zero _or_ zeros (if it's
>>>January) from the yearday, using the shell contructions:
>> Why not just go the easy route and use "+%-j", which causes date to not
>> pad with leading zeroes?
> On some systems (e.g., Solaris 9) date chokes on your suggestion:
>
> $ date +%-j
> %-j
True - that feature is a GNU extension to date (as the man page states), and
Solaris does not use the GNU userland tools.
However, since the OP didn't specify a cross-platform solution, it is a
reasonable solution to give on a Debian mailing list.
Adam
Reply to: