[英]The rename linux function not working as expected
I´m trying to rename a list of files by removing the "tmp."我正在尝试通过删除“tmp”来重命名文件列表。 string
细绳
for example 1.tmp.tax.html
will become 1.tax.html
例如
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
No output message, nothing renamed.没有 output 消息,没有重命名。 What´s wrong???
怎么了???
(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 doesn't use substitution with regular expressions. rename
from util-linux 不使用正则表达式替换。
$ rename -h
Usage:
rename [options] <expression> <replacement> <file>...
So, in your case,所以,在你的情况下,
rename .tmp. . test/*.html
BTW, when using the other rename, note that .
顺便说一句,当使用其他重命名时,请注意
.
is special in regular expressions (it matches any character but newline).在正则表达式中是特殊的(它匹配除换行符以外的任何字符)。 So, your command would remove eg
taxi
from file names, too.因此,您的命令也会从文件名中删除例如
taxi
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.