[TUHS] redirection wildness in v7

Ralph Corderoy ralph at inputplus.co.uk
Fri Nov 10 01:04:56 AEST 2017

Hi Will,

> Why does the first of these incantations not present text, but the
> second does (word is a file)? Neither errors out.
> $ <word | sed 20q
> $ <word sed 20q

That's still the case with modern-day sh(1).

explains that a simple command doesn't need to result in a command name
to execute.  In your first pipeline, there's nothing to copy the data
from the first subshell's stdin redirected from ./word to the subshell's
stdout that's pipes into sed's stdin.  Adding a command to do the copy

    <word cat | sed 20q

Cheers, Ralph.

More information about the TUHS mailing list