37 votes
Accepted

When redirecting top to a file, why does cat command on that file display output of multiple top attempts?

Some top implementation (e.g. on OpenBSD, but presumably on some Linux systems too) detects whether its output is going to the terminal or to something that isn't a terminal (to a pipe or to a file) ...
Kusalananda's user avatar
  • 323k
5 votes
Accepted

Piping and input stream redirection to same command, which input does command take?

Redirections are processed from left to right, and in Bash, after pipelines (in fact, in any POSIX shell). In cat numbers.txt | sort < words.txt the shell first sets up sort’s (future) standard ...
Stephen Kitt's user avatar
3 votes

Piping and input stream redirection to same command, which input does command take?

Is it possible for one command to accept input stream from two different sources. No; an input stream is literally just a file descriptor that someone else hands to you. Just as you only have one ...
Marcus Müller's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible