文件批量重命名
需求:
业务中有许多项目,每个项目下都有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
完毕!
通过知识/经验的分享,节省开发者的时间.