$ echo 'hello world' > >(wc)
$     1    2    12

Why output is on the prompt line and not in the separate line below? Also why expects input at the end?

Since, the command below works fine as expected.

$ ls -l > >(wc)
     32     288    2120

Please elaborate the case of echo command. And others in general.

  • 2
    What version of the bash shell do you have. Output appears in a separate line on GNU bash 4.2.45 – Inian Sep 28 '18 at 7:02
  • what is And others in general.? – jsotola Sep 28 '18 at 7:05
  • the output is on the prompt line because it is programmed to be that way .... if you want the output on the next line, then insert the newline character – jsotola Sep 28 '18 at 7:08
  • why output on prompt line even necessary? Also where to add newline character to fix it. – Prakash Bhattarai Sep 28 '18 at 7:48
  • I can replicate this on versions 4.3.42 and 4.4.12 of the Bourne Again shell. The Z shell does the right thing, in contrast. For extra fun with these versions of the Bourne Again shell, try running the command in the background. That results in the output of wc never appearing at all. – JdeBP Sep 28 '18 at 8:11

echo is a builtin command, ls is an external command. Use type echo and type ls to find which is which.

  • Neither of which is relevant, as the output in the question comes from wc, which should have run to completion by the time that the Bourne Again shell issues the prompt. I suspect a Bourne Again shell bug where it does not properly wait for processes spawned by process substitution. – JdeBP Sep 28 '18 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.