我正在尝试将文件夹中的所有临时文件连接到一个文本文件中。但我总是遇到错误:
if { [catch { exec cat /tmp/new_temp/* >> /tmp/full_temp.txt } msg] }
错误信息:
-cat: /tmp/new_temp/*: No such file or directory
如果我在 tclsh 上尝试同样的事情(没有 catch 和 exec)它会起作用
最佳答案
为什么要采用如此糟糕的方法?使用 Tcl 本身连接这些文件:
set out [open /tmp/full_temp.txt w]
fconfigure $out -translation binary
foreach fname [glob -nocomplain -type f "/tmp/new_temp/*"] {
set in [open $fname]
fconfigure $in -translation binary
fcopy $in $out
close $in
}
close $out
关于file-io - 将临时文件连接到 tcl 中的单个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13988795/