file-io - 将临时文件连接到 tcl 中的单个文件

标签 file-io tcl concatenation

我正在尝试将文件夹中的所有临时文件连接到一个文本文件中。但我总是遇到错误:

 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/

相关文章:

arrays - UILabel int 数组串联

vba - excel vba - 将两个单元格的内容连接到另一个

python - 在Python中使用多处理读取文件时的同步

arrays - TCL:如何返回数组?

javascript - 在javascript中将数组中的单个字符与字符串连接起来?

bash - 从日志文件中删除控制/特殊字符

namespaces - 在 Tcl 中查找命名空间的所有过程

java - 有没有办法强制用Java写一个文件,这样函数返回后,文件就保证写完了?

java - 如何用 Java 编写 UTF-8 文件?

java - 如何将动态值传递到 FilenameFilter 中?