如何使用preFIX /后缀命名? [英] How to rename with prefix/suffix?

查看:135
本文介绍了如何使用preFIX /后缀命名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么办 MV original.filename new.original.filename 无需重新键入原来的文件名?

How do I do mv original.filename new.original.filename without retyping the original filename?

我会想象能够做类似 MV -p =新。 original.filename 或者 MV original.filename新的〜或什么 - 但我看不出这样的事情在看<$ C后$ C> MV的人 / 信息MV 页。

I would imagine being able to do something like mv -p=new. original.filename or perhaps mv original.filename new.~ or whatever - but I can't see anything like this after looking at man mv / info mv pages.

当然,我可以写一个shell脚本来做到这一点,但是是不是有一个现有的命令/标志呢?

Of course, I could write a shell script to do this, but isn't there an existing command/flag for it?

推荐答案

在Bash和zsh中你可以用的括号扩展。这只是扩大了在括号项目清单。例如:

In Bash and zsh you can do this with Brace Expansion. This simply expands a list of items in braces. For example:

# echo {vanilla,chocolate,strawberry}-ice-cream
vanilla-ice-cream chocolate-ice-cream strawberry-ice-cream

所以,你可以做你的命名如下:

So you can do your rename as follows:

mv {,new.}original.filename

,因为这将扩展为:

as this expands to:

mv original.filename new.original.filename

这篇关于如何使用preFIX /后缀命名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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