Pipes and Error Handling
Learn how to connect streams using pipes and how to handle errors.
We'll cover the following...
Connecting streams using pipes
The concept of Unix pipes was invented by Douglas Mcllroy. This enabled the output of a program to be connected to the input of the next. Take a look at the following command:
echo Hello World! | sed s/World/Node.js/g
In the preceding command, echo
will write Hello World!
to its standard output, which is then redirected to the standard input of the sed
command (thanks to the pipe |
operator). Then, sed
replaces any occurrence of World
with Node.js and prints the result to its ...