我想在一个相对较大的项目的每个文件的顶部替换多行许可通知(从GNU GPL到Apache 2.0 )。许可通知由几段组成。另一个要求是目标许可证通知中有一个取决于当前文件名的占位符,因此简单的查找和替换是不够的。
我熟悉这样做:
find . -name "*.java" -exec sed -i 's/find/replace/g' {} \;
但我看不出如何使它适用于这个用例。
更新:
目标 Apache 2.0 许可证的占位符如下所示:
Copyright [yyyy] [name of copyright owner]
[filename.java] <br/><br/>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at<br/><br/>
http://www.apache.org/licenses/LICENSE-2.0<br/><br/>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.