3

Can someone explain me, why the following doesn't work:

echo hello | echo -

Just for learning purposes (don't tell me to use something else and not "echo" or why do I need it), I want to understand why it's not working. I'm trying to pipe the result of the first echo to the second echo (through stdin). Why is it not working and what can I do to make it work?

FLUSHER
  • 151

1 Answers1

2

You cannot make it work because echo doesn't know how to read a stream of data from stdin. It can only echo the arguments you give it, so you need to pass the data in the form of an argument. For example, like this:

echo $(echo hello)
terdon
  • 242,166