根据Unix中的模式重命名多个文件 [英] Rename multiple files based on pattern in Unix

查看:83
本文介绍了根据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.

这篇关于根据Unix中的模式重命名多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆