如何使用在bash可用工具来生成一系列nonweekend日期? [英] How to generate a range of nonweekend dates using tools available in bash?
本文介绍了如何使用在bash可用工具来生成一系列nonweekend日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要生成所在的名称由 $ {文件名}的文件列表。$ {日期}
,例如 file.20111101
, file.20120703
,从 2011年11月1日
直到今天,它应该不包括周末。
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.
感谢。
推荐答案
试试这个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
或此为NOV-2011 DEC-2013
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
这篇关于如何使用在bash可用工具来生成一系列nonweekend日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文