#!/bin/ksh -p # "The pied piper" (say pie-edd not pie'd :) # Sends marked sections of a file through a pipe and not non marked # sections # e.g. pied rot13 @@ file # on file = "Hello "Hello # @@ __\ @@ # Hello ===> Uryyb # @@ ""/ @@ # Hello" Hello" # Provided you have a unix pipe called "rot13" # # Usage: pied pipename marker filename # Usage in pine: # 1) Select alternate editor (having none set) # 2) Type: pied pipename marker # Note there's no filename! set -A params $* plen=${#params[*]} plen=$((plen-1)) filename="${params[$plen]}" unset params[$plen] plen=$((plen-1)) marker="${params[$plen]}" unset params[$plen] OLDpipe="$(print ${params[*]})" pipe=cat set -o noglob while read line ; do if [ "$line" == "$marker" ] ; then temp="$pipe" pipe="$OLDpipe" OLDpipe="$temp" fi echo $line | $pipe >> ${filename}.2 done < $filename set +o noglob mv -f ${filename}.2 ${filename}