遍历某些YYYYMMDD日期 [英] Globbing certain YYYYMMDD dates
本文介绍了遍历某些YYYYMMDD日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试按日历周向我的perl脚本提供几个文件. 它只是从bash获取所有文件:
I'm trying to feed my perl script several files by calendar week. It simply takes all the files it gets from the bash:
foreach my $input (@ARGV){
...
}
命名约定如下:
FILE_XYZ_20140908_0000.000XYZ
这个月的第一周没问题.
For the first week of the month it's no problem..
FILE_XYZ_2014090[1-7]_*
..将匹配就好了.当一天从09切换到10时,这变得越来越棘手.
是否有一种模式可以匹配从201409 08 到201409 14 的所有文件?
..will match just fine. It's getting tricky when the day switches from 09 to 10.
Is there a pattern that will match all files from 201409 08 till 201409 14?
推荐答案
我不确定Bash的较旧版本,但是我的(4.1.11(2))
I'm not sure about older versions of Bash, but in mine (4.1.11(2))
echo 9{08..14}
返回
908 909 910 911 912 913 914
在旧版本中,您必须使用更复杂的表达式(已在3.00.15(1)中进行测试):
In older versions, you have to use a more complex expression (tested in 3.00.15(1)):
echo 9{0{8..9},1{0..4}}
这篇关于遍历某些YYYYMMDD日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文