重击一线:将template _ *.txt复制到foo _ *.txt吗? [英] Bash One Liner: copy template_*.txt to foo_*.txt?

查看:54
本文介绍了重击一线:将template _ *.txt复制到foo _ *.txt吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有三个文件(template _ *.txt):

Say I have three files (template_*.txt):

  • template_x.txt
  • template_y.txt
  • template_z.txt

我想将它们复制到三个新文件(foo _ *.txt).

I want to copy them to three new files (foo_*.txt).

  • foo_x.txt
  • foo_y.txt
  • foo_z.txt

是否有一些简单的方法可以通过一个命令来执行此操作,例如

Is there some simple way to do that with one command, e.g.

cp --enableAwesomeness template _ *.txt foo _ *.txt

推荐答案


for f in template_*.txt; do cp $f foo_${f#template_}; done

这篇关于重击一线:将template _ *.txt复制到foo _ *.txt吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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