#!/bin/sh ### ==================================================================== ### @UNIX-shell-file{ ### author = "Peter Neuhaus", ### date = "22 May 1996", ### filename = "verwanzen", ### FAX = "+49-761-3251", ### email = "neuhaus@coling.uni-freiburg.de (Internet)", ### supported = "no", ### docstring = "********************************************* ### This code is hereby placed in the PUBLIC ### DOMAIN and may be redistributed without any ### restrictions other than that the author's ### name must be preserved on all copies . ### ********************************************* ### ### Place (HTML) text into all (.html and .htm) files ### just after the or tag in a ### directory hierarchy. ### ### Usage: ### verwanzen [-x] [path] ### ### -x remove text from the files ### Though the command is reversible it is strongly ### recommended to take backups!", ### changed = "Nico Reichelt 96-07-07 - new adress ### Nico Reichelt 98-07-13 - new adress", ### } ### ==================================================================== SED='/usr/bin/sed' FIND='/usr/bin/find' MV='/usr/bin/mv' THEDIR=. TEMPFILE='tkg.temp.file' if [ "xx$1" = "xx-x" ] then # extract added text shift; # get directory if specified THEDIR=${1:-${THEDIR}}; echo 'extracting TKG from .htm and .html files under '$THEDIR ; # get all files under $THEDIR THEFILES=`$FIND $THEDIR \ \( -name '*.htm' -o -name '*.html' \) \ -print`; for FILE in $THEFILES do echo $FILE ; # remove all lines between begin and end tag # (removes also multiple occurences of text) $SED -e '//,//D'\ $FILE > $TEMPFILE ; $MV $TEMPFILE $FILE; done; else # add text # get directory if specified THEDIR=${1:-${THEDIR}}; echo 'inserting TKG into .htm and .html files under '$THEDIR ; # get all files under $THEDIR THEFILES=`$FIND $THEDIR \ \( -name '*.htm' -o -name '*.html' \) \ -print`; for FILE in $THEFILES do echo $FILE ; # append lines after the body tag $SED -e '/<[bB][oO][dD][yY]/a\ \
\ \ \"TKG
\ Nehmen Sie an der Wanzenaktion teil!<\/A>\
\ ' $FILE > $TEMPFILE ; $MV $TEMPFILE $FILE; done; fi ### ====================================================================