#!/bin/bash
# Replace_HTML_Tags.bash
# 2012-03-26
# Chieh Cheng
# http://www.CynosureX.com/
# GNU General Public License (GPL) Version 2, June 1991
scriptName=`basename "$0"`
function replaceTags ()
{
string="$1"
substitute="$2"
echo "${string}" | sed "s/<[^>]*>/${substitute}/g"
}
function usage ()
{
echo " Usage: ${scriptName} \"HTML string\" \"substitute string\""
echo
echo " Use a '-' in place of the HTML string to read"
echo " from standard input (pipe)."
}
if [ $# -eq 2 ]
then
string="$1"
substitute="$2"
if [ "${string}" = "-" ]
then
while read string
do
replaceTags "${string}" "${substitute}"
done
else
replaceTags "${string}" "${substitute}"
fi
else
usage
fi