#!/bin/bash while (( "$#" )); do echo $1 cat > message < gitauth grep 'Author: ' $1 > fileauth cat gitauth fileauth | sort -u >> message rm gitauth fileauth cat >> message < tmp.fil NOTICE=`grep -n "END LEGAL" $1 | awk '{ print $1 }' ` if [ "X$NOTICE" != "X" ] then echo "found notice ending on line $NOTICE" awk 'BEGIN { P=0 } { if ( P ) print } /END LEGAL/{P=1} ' $1 >> tmp.fil else cat $1 >> tmp.fil fi cp tmp.fil $1 shift done rm message tmp.fil