【发布时间】:2012-12-04 09:02:12
【问题描述】:
我想在一个相对较大的项目的每个文件的顶部替换多行许可通知(从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.
【问题讨论】:
-
我希望您不要因此违反许可条款... ;-)
-
我是版权所有者,我可以对我的项目的新版本做任何我想做的事情;)
-
@GiovanniAzua 更新了我的回复,说明了如何添加占位符...如果占位符已经是旧通知的一部分,请告诉我 - 我认为我们应该差不多完成了。
标签: linux unix sed awk replace