我有一个问题,我在尝试在项目的所有文件中添加版权信息。由于它会影响许多目录和文件,我们的团队已经拆分了任务。 所以我们每个人都会手动更新文件。我可以自动化吗。
我尝试过:
find -exec sed -i "1i # x CONFIDENTIAL\n# _____________________\n#\n# 1997 - 2012 x Incorporated\n# All Rights Reserved.\n#\n# NOTICE: All information contained herein is, and remains\n# the property of x Incorporated and its suppliers,\n# if any. The intellectual and technical concepts contained\n# herein are proprietary to x Incorporated\n# and its suppliers and may be covered by U.S. and Foreign Patents,\n# patents in process, and are protected by trade secret or copyright law.\n# Dissemination of this information or reproduction of this material\n# is strictly forbidden unless prior written permission is obtained\n# from x Incorporated.\n" -- {} \;
我们可以通过指定文件的完整/部分名称来控制命令以影响目录中的某些文件吗?
答案 0 :(得分:1)
您可以通过对每个文件执行以下命令来执行此操作:
cp file temp
cat copy_right_notice temp > file
请注意,>
会覆盖file
(>>
附加到文件,这不是您想要的(参考您的评论))