【发布时间】:2020-12-08 05:16:25
【问题描述】:
我不想设置 $outfile 这么多次,我想增加文件名。 我在 TCL 中如何做到这一点?
set incr 1
set outfile [open "file$incr.txt" w]
set infile1 "[glob /a/b/c/d/a12b.txt /a/e/c/e/c123d.txt /e/e/d/e/2abd.txt ]"
set infile2 "[glob /a/b/c/d/a12b.txt /a/e/c/e/c123d.txt /e/e/d/e/2abd.txt ]"
set infile3 "[glob /a/b/c/d/a12b.txt /a/e/c/e/c123d.txt /e/e/d/e/2abd.txt ]"
foreach infile $infiles$incr {
puts $oufile$incr "testing"
}
但是,我上面的代码,似乎不起作用?
【问题讨论】:
-
你为什么在没有任何通配符的绝对路径上使用
glob? -
任何时候你有变量变量名,考虑使用数组。