This works as expected
$> cat ./readfromstdin.sh echo reading cat /dev/stdin $> echo hello | ./readfromstdin.sh reading hello
I am trying to achieve something similar without a temporary file. My first attempt was
echo hello | (echo cat /dev/stdin|sh)
which did not work. With a heredoc it did not work either (though I am not sure what the right syntax would be:
echo hello | (cat << EOF | sh cat /dev/stdin EOF) pipe cmdsubst pipe heredoc>
Is it possible to read from stdin using a script piped to the shell?