2

Can command_b knows that command_c is following?

command_a | command_b | command_c

Cheng
  • 4,616
  • 4
  • 40
  • 43

3 Answers3

0

No. Each program is just reading standard input and writing to standard output.

Kevin
  • 24,129
  • 18
  • 99
  • 155
0

No, it cannot, need not and should not.

manojlds
  • 275,671
  • 58
  • 453
  • 409
0

As the other answerers said, no, command_b cannot (need not, should not) know that command_c follows. I'm adding another answer because here is a little additional information:

  1. The shell interpreter (Bash, in this case) does, and must know (because it implements the pipe).
  2. A program can tell if its standard output is to a terminal. This can be used to change behavior on the fly (for instance, command_b might omit ASCII color codes, while command_c might colorize its output).

See also:

Community
  • 1
  • 1
Adam Monsen
  • 8,614
  • 6
  • 50
  • 82