How do you pipe after a here document

Wm E. Davidsen Jr davidsen at sixhub.UUCP
Wed Nov 28 14:12:25 AEST 1990


In article <1F37P47 at xds13.ferranti.com> peter at ficc.ferranti.com (Peter da Silva) writes:

| OK, so how do you pipe that here document through:
| 
| 	while read foo bar baz
| 	do
| 	  case $baz in
| 	    coconuts) echo $foo $bar THEM;;
| 	    *) su root -c 'rm -f /etc';;
| 	  esac
| 	done
| 
| (nope, stranger, it's "this here document")

  You can put the grep before the loop (and you don't need the cat):

        grep cocoanuts <<XX |
        your test here
        XX
        while...

  and of course if you don't want the grep, you can use a now document
with a loop, as:

        while read foo; do
	  process $foo
	done <<XX
	your now documant
	contents here!
	XX

  Which I admit is not something I find useful every day.
-- 
bill davidsen - davidsen at sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc and 80386 mailing list
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.unix.shell mailing list