1

I expect cat in the following command substitution, process substitution, and pipeline to accept stdin input, but

  1. Why does it not output anything, after I provide stdin input hello

    $ echo $(cat)
    hello
    
  2. Why does it not let me provide stdin input

    $ echo <(cat)
    /dev/fd/63
    
  3. which cat accepts my stdin input hello, and which cat outputs hello to stdout

    $ cat | cat
    hello 
    hello
    
  • echo $(cat <<< "hello") – jordanm May 30 '16 at 23:11
3
  1. You should end your input with EOF (Ctrl+d) otherwise cat does not exit.

  2. echo echoes the fd and then exits, thus closing the output descriptor of cat, which in response exits.

  3. first cat's input is stdin, second's cat output is connected to stdout. first cat's output and second cat's input are connected together with a pipe.

  • about 2, in command1 <(command2), are the two comands running at the same time, or one starts after the other finishes running? – Tim May 31 '16 at 1:41
  • these are running concurrently – adonis May 31 '16 at 8:35

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.