Search code examples
headerlanguage-agnostic

Tool for adding license headers to source files?


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


Solution

  • #!/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