How do you pipe after a here document

David W. Tamkin dattier at ddsw1.MCS.COM
Sat Nov 10 16:50:23 AEST 1990


afsipmh at cidsv01.cid.aes.doe.CA (Pat Hertel) wrote in
<1990Nov8.201508.13222 at cid.aes.doe.CA>:

|  I want to do something like the following:
| 
| #! /bin/sh
| cat <<END
| I,ve got
| a lovely
| bunch of coconuts
| END 
| | grep coconuts
| 
| The above doesn't work so how can I do it?

Two other people have suggested

cat << END | grep coconuts
I've got 
a lovely
bunch of coconuts
END

That works in sh, and so does this:

{ cat << END
I've got
a lovely
bunch of coconuts
END                    # or END ;} | grep coconuts
} | grep coconuts      #

and, believe it or not, so does this:

grep coconuts << END
I've got 
a lovely
bunch of coconuts
END

David Tamkin  Box 7002  Des Plaines IL  60018-7002  708 518 6769  312 693 0591
MCI Mail: 426-1818  GEnie: D.W.TAMKIN  CIS: 73720,1570   dattier at ddsw1.mcs.com



More information about the Comp.unix.shell mailing list