Description
If a file does not begins with the following block:
/*
* My copyright
* 2009
*/
then prepend that block to the file.
Raw Input Desired Output
line 1
line 2
line 3
line 4
line 5
line 6
line 7
/*
 * My copyright
 * 2009
 */
line 1
line 2
line 3
line 4
line 5
line 6
line 7
Script and Comments
Script1
[ 1] $!N
[ 2] $!N
[ 3] $!N
[ 4] /\/\*\n \* My copyright\n \* 2009\n \*\//!i\
[ 5] /*\
[ 6] * My copyright\
[ 7] * 2009\
[ 8] */
[ 9] :loop
[10] n
[11] b loop
Comments
  1. Since the desired block contains 4 lines, to check whether the file begins with the desired block, Steps [1] thru [3] are used to append to PS the second through the fourth lines of the datafile.
  2. If the datafile contains less than 4 lines, and commands `N' of Steps [1] thru [3] are not preceded with $!, once some `N' is performed after reading the last line, sed prints all contents of PS and then terminates. This is exactly not what we want.
  3. If the datafile does not contains the desired block, command `i' of Steps [4] thru [8] inserts the specified lines before the first line.
  4. Steps [9] thru [11] constitute a loop which prints the remaining lines of the file.