TCL onliner:替换filename中的字符串

时间:2017-02-03 07:49:34

标签: replace tcl

有没有办法用onLiner用TCL替换文件名中的字符串。例如,使用perl它将是:

文件:

testA1.txt
testA2.txt
testA3.txt

Oneliner

perl -e "while(<test*>) {($new=$_) =~ s/A/B/; rename $_, $new}"

文件

testB1.txt
testB2.txt
testB3.txt

一般来说,TCL是否适合oneliners?正如我在Perl和Powershell中找到的那样,我在TCL的网络上找不到。

操作系统:Windows 7

1 个答案:

答案 0 :(得分:1)

我能想到的最简单的就是:

foreach f [glob test*] {file rename $f [string map {A B} $f]}

与任何语言一样,一个衬垫通常用于快速和脏的东西或乐趣。不是你在适当的代码中找到的东西。

相关问题