2

Can command_b knows that command_c is following?

command_a | command_b | command_c

Cheng
  • 4,816
  • 4
  • 41
  • 44

3 Answers3

0

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

Kevin
  • 24,871
  • 19
  • 102
  • 158
0

No, it cannot, need not and should not.

manojlds
  • 290,304
  • 63
  • 469
  • 417
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
  • 9,054
  • 6
  • 53
  • 82