#!/bin/sh # replacer by David Dumas if [[ $# -lt 2 ]]; then echo "USAGE: replacer [file] [replacement]" echo "" echo "If [file] contains the first and last lines of" echo "[replacement], then everything between them is" echo "replaced with the contents of [replacement]." exit 1 fi if [ ! -f "$1" ]; then echo "File not found: \"$1\"." exit 127 fi if [ ! -f "$2" ]; then echo "File not found: \"$2\"." exit 127 fi rep_start=`cat $2 | head -1` rep_end=`cat $2 | tail -1` ed $1 << EOF > /dev/null 2>&1 /$rep_start/,/$rep_end/c `cat $2` . w EOF