How to pipe command output to other commands?
Problem
Example: prints nothing ( a blank line, actually ). I'd expect it to print a list of files. , on the other hand, works as expected ( prints files with 'foo' in their name ). What I do in these situations is something like: but this is rather cumbersome. Why does piping work with some commands, but not with others ? How can I circumvent this issue ?
Error Output
ls | echo
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to pipe command output to other commands?
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 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 - to its own stdout. The output: nothing at all. There are a few solutions in this case. One is to use a command that reads stdin and dumps to stdout, such as cat.…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix