我的文件夹如下:
RBS_delete20150518-170641.xml
RBS_delete20150517-160545.xml
...
我使用expect
程序,但无法使用正则表达式处理日期戳:
if {[file exists /home/ARNE/ARNE/SCRIPTS/RBS_delete[0-9].xml]}
答案 0 :(得分:2)
file exists
不支持regexp
模式。您可以使用glob
。
set myfiles [ glob -nocomplain "/home/ARNE/ARNE/SCRIPTS/*.xml" ]
if {[llength $myfiles]!=0} {
puts "Following XML files found : "
foreach fname $myfiles {
puts $fname; # Now you can process these elements as per your wish
if {[regexp {RBS_delete\d+\-\d+\.xml} $fname]} {
puts " file name pattern matched"
}
}
} else {
puts "No XML files available"
}