文件批量重命名

需求:
业务中有许多项目,每个项目下都有xxx.test.yml文件,将xxx.test.yml 复制为xxx.test-container.yml
比如:
/Users/bbb/Documents/aaa-openpay/common/aaa-config/src/main/resources/config/aaa-service-user/aaa-service-user-test.yml
/Users/bbb/Documents/aaa-openpay/common/aaa-config/src/main/resources/config/aaa-service-account/aaa-service-account-test.yml

1 复制文件
find config//test.yml -exec cp {} {}-xxxx.yml ;

2 重命名文件
for file in find config/*/*test.yml-xxxx.yml
do
newfile=echo $file | sed 's/test.yml-xxxx.yml/test-container.yml/'
mv $file $newfile
done

完毕!

posted @ 2021-06-01 14:06  ysloong  阅读(60)  评论(0编辑  收藏  举报