Bash One Liner:将模板_*.txt复制到foo _*.txt?

Pat*_*ney 9 bash

假设我有三个文件(模板_*.txt):

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

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

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

有一些简单的方法可以用一个命令来做到这一点,例如

cp --enableAwesomeness template_*.txt foo_*.txt

Chr*_*way 11

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