How do you pipe after a here document
Jon H. LaBadie
jon at jonlab.UUCP
Sun Nov 11 10:39:18 AEST 1990
In article <1990Nov8.201508.13222 at cid.aes.doe.CA>, afsipmh at cidsv01.cid.aes.doe.CA writes:
>
> 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?
The pipe symbol (not necessarily the command, but the symbol)
must be on the current command line. The current command line
is "cat ...".
Either of the following will work:
cat <<END | grep coconuts
...
END
or
cat <<-END |
...
END
grep coconuts
Note, in the second example, I also used the "-" notation of the
here document to allow the document to be indented by tabs.
This has no effect on the pipeline and could be omitted. It is
a readability issue.
Jon
--
Jon LaBadie
{att, princeton, bcr, attmail!auxnj}!jonlab!jon
More information about the Comp.unix.shell
mailing list