I want to generate a list of files where the name consists of ${filename}.${date}
, for example file.20111101
, file.20120703
, starting November 1, 2011
until today and it should exclude weekends.
Thanks.
I want to generate a list of files where the name consists of ${filename}.${date}
, for example file.20111101
, file.20120703
, starting November 1, 2011
until today and it should exclude weekends.
Thanks.
This might work for you (GNU date,sed and Bash):
Explanation:
seq
provides a sequence of days from20111101
totoday
sed
filters out the weekendsxargs
feeds day parameters for thedate
command.Another option is to use
dateseq
fromdateutils
(http://www.fresse.org/dateutils/#dateseq).try this for 2011
or this for NOV-2011 to DEC-2013
or until end of this month "hard"
A solution with gawk:
This uses a nice property of mktime that automatically find the correct date when you increment one of the date components (e.g. "2012-02-33" becomes "2012-03-04").