用于将源许可证头添加到源文件的工具? [英] Tool for adding license headers to source files?

查看:87
本文介绍了用于将源许可证头添加到源文件的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种工具,可以批量将许可证标题添加到某些源文件,其中一些源文件已具有标题。有没有一个工具可以插入一个标题,如果它还没有出现?



编辑:我故意不标记这个问题的答案,因为答案基本上都是针对特定环境和主观的

解决方案 / bin / bash

用于* .cc#或其他任何模式...

if! grep -q版权$ i
然后
cat copyright.txt $ i> $ i.new&& mv $ i.new $ i
fi
完成


I'm looking for a tool that will, in bulk, add a license header to some source files, some of which already have the header. Is there a tool out there that will insert a header, if it is not already present?

Edit: I am intentionally not marking an answer to this question, since answers are basically all environment-specific and subjective

解决方案

#!/bin/bash

for i in *.cc # or whatever other pattern...
do
  if ! grep -q Copyright $i
  then
    cat copyright.txt $i >$i.new && mv $i.new $i
  fi
done

这篇关于用于将源许可证头添加到源文件的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆