#!/bin/sh # Script to "multiple file sed" (or, "msed"). # You give it the sed string and the files and it does the rest. # # I.e.: ./msed 's/old string/new string/g' *.html # # Global replace of 'old string' with 'new string' to all .html files. # #--- # multiple file sed # # Mark Allman (mallman@grc.nasa.gov) if [ $# -lt 2 ] then echo "usage: `basename $0` sed_string files" exit 1 fi STRING=$1 shift FILES=$@ TAROPTS="czf" echo "Backing up old files..." rm -f backup.tgz tar $TAROPTS backup.tgz $FILES echo "Done." echo echo "Applying Changes" for I in $FILES do echo " $I" sed -e "$STRING" $I > $$ mv $$ $I done exit 0