(via https://stackoverflow.com/a/8624829/23582)
How does (head; tail) < file
work? Note that cat file | (head;tail)
doesn\'t.
Al
the parenthesis here create a subshell
which is another instance of the interpreter to run the commands that are inside, what is interesting is that the subshell acts as a single stdin/stdout combo; in this case it'll first connect stdin to head
which echoes the first 10 lines and closes the pipe then the subshell connects its stdin to tail
which consumes the rest and writes back the last 10 lines to stdout, but the subshell takes both outputs and writes them as its own stdout and that's why it appears combined.
it's worth mentioning that the same effect could be achieved with command grouping like { head; tail; } < file
which is cheaper because it doesn't create another instance of bash.