如何在TCL中`rm -rf *` [英] How to `rm -rf *` in TCL
本文介绍了如何在TCL中`rm -rf *`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用TCL删除目录中的所有文件.(我在Win 10下使用Xilinx Vivado的TCL控制台.)我在
I want to delete all files in a directory using TCL. (I'm using Xilinx Vivado's TCL console under Win 10.) I found that in TCL documentation that
file delete ?-force? ?- -? pathname ?pathname ... ?
应该工作.但是
file delete -force -- [glob *]
什么都不做.怎么了?
推荐答案
做到这一点
file delete -force -- {*}[glob *]
...,以便将 [glob]
返回的路径名转换为 [file delete]
的多个参数(使用扩展运算符 {*}
),而不是代表一个路径名列表的一个参数(由 [file delete]
读取为一个非常复杂的文件路径).
... so that the path names returned by [glob]
are turned into multiple arguments to [file delete]
(using the expansion operator {*}
), rather than one argument representing the one list of a path names (read by [file delete]
as one, well complex file path).
或者,在8.5之前的Tcl上,使用显式循环:
Alternatively, on Tcl older than 8.5, use an explicit loop:
foreach path [glob *] {
file delete -force -- $path
}
这篇关于如何在TCL中`rm -rf *`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文