Article View: comp.unix.shell
Article #1753Re: How do you pipe after a here document
From: Jon H. LaBadie
Date: Sat, 10 Nov 1990 23:39
Date: Sat, 10 Nov 1990 23:39
41 lines
1320 bytes
1320 bytes
In article <1990Nov8.201508.13222@cid.aes.doe.CA>, afsipmh@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
Technical Details
Message-ID:
<873@jonlab.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!udel!princeton!jonlab!jonReferences:
<1990Nov8.201508.13222@cid.aes.doe.CA>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!udel!princeton!jonlab!jon From: jon@jonlab.UUCP (Jon H. LaBadie) Newsgroups: comp.unix.shell Subject: Re: How do you pipe after a here document Summary: put the pipe on the command line Message-ID: <873@jonlab.UUCP> Date: 10 Nov 90 23:39:18 GMT References: <1990Nov8.201508.13222@cid.aes.doe.CA> Distribution: na Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 41