adding a header to some files

I had a need to need a header to all java files in a project. As this amounted to several hundred files (no I did not count them, would not want to do that), I wrote a little script to do the work. Which is quite trivial thanks to the power of bash and linux command line tools.


#!/bin/sh
for fn in `find . -name '*.java'`
do
  cp $fn "$fn".copy
  cat header.txt "$fn".copy >$fn
  rm "$fn".copy
done

Just put this script in the base directory together with a “header.txt” file which contains the header which needs to be prepended (be sure that this file ends in a newline), execute and… all done.

Leave a Reply

Your email address will not be published. Required fields are marked *

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

*