link.sh


### link.sh
###
### If targetfile contains a reference to filename, create a link to
### relative_path/filename.html.
###
###
###  Usage:
###
###        link.sh relative_path\\/filename.html targetfile
###
###
###  Notes: Owing to Unix special char quirks, double backslashes are required
###         in front of slashes in the path.
###
###
###         The spaces in the regexp below includes both a space and a tab
###         The spaces in the regexp below includes both a space and a tab
###
###         Suggested improvements to this script are welcome.
###  Send them to webmaster@setgetweb.com
###

xfile=$1
tfile=$2
xstring=`basename $xfile .html`
sed "/${xstring}[,      ]/s/${xstring}/<a href=\\\"$xfile\\\">${xstring}<\/a>/g" $tfile > tmp.$$
sed "/[,        ]${xstring}/s/${xstring}/<a href=\\\"$xfile\\\">${xstring}<\/a>/g" tmp.$$ > $tfile