小编dev*_*ili的帖子

使用正则表达式在 Bash 中重命名文件

我有一个名为的文件35554842200284685106000166550020003504201637715423.xml,我只需将其重命名为42200284685106000166550020003504201637715423.xml(删除最后 48 个字符之前的所有内容)。这个简单的正则表达式 ( .{48}$) 可以提取最后 48 个字符,但我无法rename在 Bash 中使用它。

如何使用rename此正则表达式将其重命名为仅最后 48 个字符?

编辑:

输出 rename --help

[root@ip-000-00-0-000 tmp]# rename --help

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

Rename files.

Options:
 -v, --verbose    explain what is being done
 -s, --symlink    act on the target of symlinks
 -n, --no-act     do not make any changes

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see rename(1). …
Run Code Online (Sandbox Code Playgroud)

bash rename

8
推荐指数
3
解决办法
2268
查看次数

标签 统计

bash ×1

rename ×1