#!/bin/bash findmgroot(){ PRG="$0" while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` MGROOT=`cd "$PRGDIR/.." ; pwd` if [ -z "$MGROOT" ]; then echo "ERR_MGROOT_NOT_DEFINED" return $ERR_MGROOT_NOT_DEFINED else return $OK fi } if [ $# -lt 1 ];then # usage exit 0 fi dir=$1 MYGRID_LICENSE_FILE="$MGROOT/resources/CODELICENSE" for i in `find $dir -name "*.java"` do echo "Deleting header in file $i" ed $i << EOF /^ *package .-1 1,. d w q EOF #do not indent the line above. EOF must be in the first column ;-( echo "Appending header in file $i" MYGRID_LICENSE_TMP=$i.tmp.$$ cp $MYGRID_LICENSE_FILE $MYGRID_LICENSE_TMP cat $i >> $MYGRID_LICENSE_TMP mv -f $MYGRID_LICENSE_TMP $i done