Question
Why do shells implement alternative means like <<<
, < <(command)
and < /dev/fd/*
to redirect something to stdin
when pipes do exist?
Example
The |
way (classic pipes)
echo 'text' | sed 's/x/y/'
# or
cat - | sed 's/x/y/' # type text afterwards
The <<<
way
sed 's/x/y/' <<< 'text'
The < <(command)
way
sed 's/x/y/' < <(echo 'text')
# while <(command) becomes a file descriptor like
sed 's/x/y/' < /dev/fd/42
All of them return teyt
.
tr ... < <(cat some-file)
orcat some-file | tr ...
instead of justtr ... < some-file
? Why?<
, redirecting the process substitution, which is a pathname. This makes it no more "special" than redirecting from some file, just like with redirecting from stuff beneath/dev/fd
.