There is a distinction between command line arguments and standard input. A pipe will connect standard output of one process to standard input of another. So
ls | echo
Connects standard output of ls to standard input of echo. Fine right? Well, echo ignores standard input and will dump its command line arguments - which are none in this case to - its own stdout.
There are a few solutions in this case. One is to use a command that reads stdin and dumps to stdout, such as cat.
ls | cat
Will 'work', depending on what your definition of work is.
But closer to what you want is to converting stdout to command line args. As others have said, xargs is the canonical tool in this case, reading it's command line args for a command, then stdin and constructing commands to run.
ls | xargs echo
You could also convert this some, using the substitution command $()
echo $(ls)
Would also do what you want.
Both of these tools are pretty core to shell scripting, you should learn both.
ls | echoto do? why not simply runls? – theomega Sep 16 '10 at 13:46git cat-file, but it just didn't work. Apparently, echo has the same behaviour, so I used it as an example. – Mihai Rotaru Sep 16 '10 at 14:10