Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: exec | wc isn't very useful...

Anthony Heading wrote:
> Hi,
> Can anyone tell me why this doesn't do what I'd hope:
>     exec | wc

The syntax doesn't make sense.  You're piping the output of "exec" on
its own, which doesn't do anything, to "wc".  A pipeline is
fundamentally different from a redirection.

> I'm wondering how to redirect the shell's "default" stdout into
> a process, e.g. do the equivalent of perl's
>     open(STDOUT, "| wc");
>     print "two words";

Try this:

exec > >(wc)

Something like this got broken at one point (by me) but is working in
the latest version of the shell.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.


Messages sorted by: Reverse Date, Date, Thread, Author