#!/bin/sh ######################################################################### # # FILE : striphtml # DATE : 26.01.2001 # AUTHOR : Patrick Meier / patrick.meier@gmx.net # DESCRIPTION : remove HTML tags from input # # Copyrigth (C) 2001 by Patrick Meier, Switzerland # ######################################################################### PN=`basename "$0"` ######################################################################### # Usage ######################################################################### Usage() { echo "$PN - strip HTML tags from input" echo "usage: $PN [file ...]" exit 1 } ######################################################################### # main ######################################################################### [ $# -lt 1 ] && Usage # "getopt" detected an error while [ $# -gt 0 ] do case "$1" in # your flags here --) shift; break;; -h) Usage;; -*) Usage;; *) break;; # First file name esac shift done # Transform the input the following way: # 1. Replace "
" tags with a newline (special handling) # 2. Remove all Tags delimited by "<..>" # 3. Remove character entities (i.e. "©" or " ") sed -e 's:<[bB][rR]>:\ :g' \ -e 's:<[^>]*>::g' \ -e 's:&..;::g; s:&...;::g; s:&....;::g' \ "$@" ######################################################################### # EOF #########################################################################