Piping output from multiple programs

With what we've learned so far, it's easy to combine the output of two separate commands into a file; we just run them in the appropriate sequence, and use the redirection output with >> to append the data:

$ date > myout
$ hostname >> myout
$ cat myout
Mon Jul 30 21:32:33 NZST 2018
bashserver.example.net.

However, it may not be clear how you could combine two streams of output from commands into one without saving them into a temporary file, for example to capitalize all of the letters within it with tr. There isn't a specific syntax to "merge" pipes.

There is still a way to do this without resorting to a temporary file; you can use a compound command that contains all of the commands for output redirection, ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.