根据Unix中的模式重命名多个文件

根据Unix中的模式重命名多个文件

问题描述:

目录中存在多个以前缀fgh开头的文件,例如:

There are multiple files in a directory that begin with prefix fgh, for example:

fghfilea
fghfileb
fghfilec

我想重命名所有这些文件,使其以前缀jkl开头.有一个命令可以做到这一点,而不是单独重命名每个文件吗?

I want to rename all of them to begin with prefix jkl. Is there a single command to do that instead of renaming each file individually?

有几种方法,但是使用rename可能是最简单的方法.

There are several ways, but using rename will probably be the easiest.

使用 rename 的一个版本:

Using one version of rename:

rename 's/^fgh/jkl/' fgh*

使用 rename 的另一个版本(与您应检查平台的手册页,以查看以上哪一项适用.

You should check your platform's man page to see which of the above applies.