与批量重命名猛砸 [英] Batch Renaming with Bash

查看:103
本文介绍了与批量重命名猛砸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何猛砸重命名一系列软件以消除他们的版本号?我一直在玩弄与周围两个 EXPR %% ,都无济于事。

How can Bash rename a series of packages to remove their version numbers? I've been toying around with both expr and %%, to no avail.

例如:

Xft2-2.1.13.pkg 变成 Xft2.pkg

碧玉1.900.1.pkg 变成 jasper.pkg

的xorg-libXrandr-1.2.3.pkg 变成的xorg-libXrandr.pkg

推荐答案

您可以使用bash中的参数扩展功能

You could use bash's parameter expansion feature

for i in *.pkg ; do mv "$i" "${i/-[0-9.]*.pkg/.pkg}" ; done

需要与空格的文件名

行情

Quotes are needed for filenames with spaces.

这篇关于与批量重命名猛砸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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