linux批量重命名文件

现实中我们常会给文件批量重命名, 利用linux的重命名命令rename可以做到这一点

可以看到rename的from、to、files三个参数

from:修改的内容,to:改成的内容,files:改的文件,通常用通配符表示

比如有这样一批文件,想去掉后边的.COMPLETED,这是可以用rename批量重命名

bi.2018-07-02-00-00.log.COMPLETED  bi.2018-07-02-04-01.log.COMPLETED  bi.2018-07-02-08-02.log.COMPLETED  bi.2018-07-02-12-03.log.COMPLETED
bi.2018-07-02-00-01.log.COMPLETED  bi.2018-07-02-04-02.log.COMPLETED  bi.2018-07-02-08-03.log.COMPLETED  bi.2018-07-02-12-04.log.COMPLETED
bi.2018-07-02-00-02.log.COMPLETED  bi.2018-07-02-04-03.log.COMPLETED  bi.2018-07-02-08-04.log.COMPLETED  bi.2018-07-02-12-05.log.COMPLETED
bi.2018-07-02-00-03.log.COMPLETED  bi.2018-07-02-04-04.log.COMPLETED  bi.2018-07-02-08-05.log.COMPLETED  bi.2018-07-02-12-06.log.COMPLETED
bi.2018-07-02-00-04.log.COMPLETED  bi.2018-07-02-04-05.log.COMPLETED  bi.2018-07-02-08-06.log.COMPLETED  bi.2018-07-02-12-07.log.COMPLETED
bi.2018-07-02-00-05.log.COMPLETED  bi.2018-07-02-04-06.log.COMPLETED  bi.2018-07-02-08-07.log.COMPLETED  bi.2018-07-02-12-08.log.COMPLETED
bi.2018-07-02-00-06.log.COMPLETED  bi.2018-07-02-04-07.log.COMPLETED  bi.2018-07-02-08-08.log.COMPLETED  bi.2018-07-02-12-09.log.COMPLETED
bi.2018-07-02-00-07.log.COMPLETED  bi.2018-07-02-04-08.log.COMPLETED  bi.2018-07-02-08-09.log.COMPLETED  bi.2018-07-02-12-10.log.COMPLETED
bi.2018-07-02-00-08.log.COMPLETED  bi.2018-07-02-04-09.log.COMPLETED  bi.2018-07-02-08-10.log.COMPLETED  bi.2018-07-02-12-11.log.COMPLETED
bi.2018-07-02-00-09.log.COMPLETED  bi.2018-07-02-04-10.log.COMPLETED  bi.2018-07-02-08-11.log.COMPLETED  bi.2018-07-02-12-12.log.COMPLETED

rename    log.COMPLETED  log  *.COMPLETED 

将带有*.COMPLETED文件中的 log.COMPLETED改为为log

可以看到已经变啦

bi.2018-07-02-00-00.log  bi.2018-07-02-04-01.log  bi.2018-07-02-08-02.log  bi.2018-07-02-12-03.log
bi.2018-07-02-00-01.log  bi.2018-07-02-04-02.log  bi.2018-07-02-08-03.log  bi.2018-07-02-12-04.log
bi.2018-07-02-00-02.log  bi.2018-07-02-04-03.log  bi.2018-07-02-08-04.log  bi.2018-07-02-12-05.log
bi.2018-07-02-00-03.log  bi.2018-07-02-04-04.log  bi.2018-07-02-08-05.log  bi.2018-07-02-12-06.log
bi.2018-07-02-00-04.log  bi.2018-07-02-04-05.log  bi.2018-07-02-08-06.log  bi.2018-07-02-12-07.log
bi.2018-07-02-00-05.log  bi.2018-07-02-04-06.log  bi.2018-07-02-08-07.log  bi.2018-07-02-12-08.log
bi.2018-07-02-00-06.log  bi.2018-07-02-04-07.log  bi.2018-07-02-08-08.log  bi.2018-07-02-12-09.log
bi.2018-07-02-00-07.log  bi.2018-07-02-04-08.log  bi.2018-07-02-08-09.log  bi.2018-07-02-12-10.log
bi.2018-07-02-00-08.log  bi.2018-07-02-04-09.log  bi.2018-07-02-08-10.log  bi.2018-07-02-12-11.log
bi.2018-07-02-00-09.log  bi.2018-07-02-04-10.log  bi.2018-07-02-08-11.log  bi.2018-07-02-12-12.log

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值