[OT] How to prepend copyright notices to each source file

Sorry for the off-topic post, but I guess someone else may hit the same
issue…

Having developed a rails application, I now need to put GPL text and a
copyright notice at the start of each source file. For the .rb files,
this
will look like:

Copyright 2006 Robert J…

and for the .rhtml files it will look like:

<!-- Copyright 2006 Robert J.......... Can anyone think of a neat way to do this prepending programatically on Linux, rather than by hand? I'm sure I can be done with awk, sed, grep etc. Thanks in advance, -- Robert J.

make a script addhead in root directory:

#!/bin/sh
cat $2 $1 > $1.tmp
mv $1.tmp $1

then execute
find . -name “*.rb” -exec ./addhead {} header.txt ;

Michael J.

If you’re using a layout file, put it in there.

If you’re resorting to sed/awk/etc. for stuff like this, personally
I’d think that your design needs to be looked at and possibly
refactored.

Layouts are incredibly handy…

Regards

Dave M.

On 12-feb-2006, at 0:13, David M. wrote:

Having developed a rails application, I now need to put GPL text
and a
copyright notice at the start of each source file.

If you’re using a layout file, put it in there.

If you’re resorting to sed/awk/etc. for stuff like this, personally
I’d think that your design needs to be looked at and possibly
refactored.

Refactored? He wanted the notice “at the start of each source file.”


Regards, Charles.

Thanks Michael - works like a charm. So simple too.

Robert

Ah, my mistake - I read it as though he wanted to have a copyright
notice on each (published) page.