开发者社区 问答 正文

复制和重命名文件-Linux cp命令

我的目录中有以下文件。

tom_aaa.txt  
    tom_bbb.txt  
    tom_ccc.txt

我想复制这些文件并通过使用shell命令(MAC / LINUX / UNIX)用jerry替换tom来重命名它们。

预期结果:

tom_aaa.txt  
tom_bbb.txt  
tom_ccc.txt  
jerry_aaa.txt  
jerry_bbb.txt  
jerry_ccc.txt

展开
收起
祖安文状元 2020-01-06 15:27:30 658 分享 版权
1 条回答
写回答
取消 提交回答
  • 找到了一种方法。

    for i in `ls *`; do cp $i `echo $i | sed "s/tom/jerry/g"`; done
    
    2020-01-06 15:27:39
    赞同 展开评论