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?
pipe through sed like either of these: date +%j |sed 's/^0+//' date +%j |sed -r 's/^0?//' On some systems (e.g., Solaris 9) date chokes on your suggestion: $ date +%-j %-j Incidentally, my second suggestion also does not work on Solaris 9 (since it does not use GNU sed). -Roberto -- Roberto C. Sanchez http://familiasanchez.net/~sanchezr
Attachment:
signature.asc
Description: OpenPGP digital signature