繁体   English   中英

重命名 linux function 未按预期工作

[英]The rename linux function not working as expected

我正在尝试通过删除“tmp”来重命名文件列表。 细绳

例如1.tmp.tax.html将变为1.tax.html

(base) [david@archlinux ~]$ ls -ltr test/
total 684
-rw------- 1 david users 229779 Nov  7 11:43 1.tmp.tax.html
-rw------- 1 david users 229779 Nov  7 11:43 2.tmp.tax.html
-rw------- 1 david users 229779 Nov  7 11:43 3.tmp.tax.html


rename 's/tax.//' test/*.html

没有 output 消息,没有重命名。 怎么了???

(base) [david@archlinux ~]$ rename --version
rename from util-linux 2.34

(base) [david@archlinux ~]$ uname -a
Linux archlinux 5.3.7-arch1-2-ARCH #1 SMP PREEMPT @1572002934 x86_64 GNU/Linux

rename from util-linux 不使用正则表达式替换。

$ rename -h

Usage:
 rename [options] <expression> <replacement> <file>...

所以,在你的情况下,

rename .tmp. . test/*.html

顺便说一句,当使用其他重命名时,请注意. 在正则表达式中是特殊的(它匹配除换行符以外的任何字符)。 因此,您的命令也会从文件名中删除例如taxi

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM