How do you pipe after a here document

Paul Chamberlain tif at doorstop.austin.ibm.com
Wed Nov 28 04:15:25 AEST 1990


peter at ficc.ferranti.com (Peter da Silva) writes:
[asks how to pipe a here document to a complicated command.]

Actually, the solution was given in one of the original answers,
but it was among several other solutions so it may have been missed.

	#! /bin/sh
	# If sh sees a pipe it knows the command is continued
	cat <<END |
	I,ve got
	a lovely
	bunch of coconuts
	END
	grep coconuts |
	while read foo bar baz
		do
	  case $baz in
	    coconuts) echo $foo $bar THEM;;
	    *) echo su root -c 'rm -f /etc';;
	  esac
	done

On my RT this prints

	bunch of THEM

Paul Chamberlain | I do NOT represent IBM.     tif at doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif



More information about the Comp.unix.shell mailing list