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.
try this for 2011
for y in 2011; do
for m in {1..12}; do
for d in `cal -m $m $y|tail -n +3|cut -c 1-15`; do
printf "file.%04d%02d%02d\n" $y $m $d;
done;
done;
done
or this for NOV-2011 to DEC-2013
for ym in {2011' '{11,12},{2012..2013}' '{1..12}}; do
read y m <<<$ym;
for d in `cal -m $m $y|tail -n +3|cut -c 1-15`; do
printf "file.%04d%02d%02d\n" $y $m $d;
done;
done
or until end of this month "hard"
for ym in {2011' '{11,12},2012' '{1..7}};do
read y m <<<$ym;
for d in `cal -m $m $y|tail -n +3|cut -c 1-15`;do
printf "file.%04d%02d%02d\n" $y $m $d;
done;
done