On Saturday, May 10, 2014 03:31:05 PM Dan Douglas wrote: 
>  $ bash -c 'printf -v a "%(%s)T" -1; printf "%(%Y%m%d)T " "$a" 
"${a[a+=60*60*24,0]"{0..8}"}"; echo'
> 20140510 20140511 20140512 20140513 20140514 20140515 20140516 20140517 
20140518 20140519

By the way, I'm not very good at remembering the winking smiley when my 
solutions are not entirely serious, so here it is: ;-)

Also, I didn't notice you meant to count backwards. GNU date has a better 
solution anyway by reading date formats with "-f". The downside is it appears 
to only do newline-delimited input and output. 

$ printf 'now - %d days\n' {0..9} | date -f - +%Y%m%d | tr '\n' ' '; echo
20140510 20140509 20140508 20140507 20140506 20140505 20140504 20140503 
20140502 20140501

-- 
Dan Douglas


Reply via email to