Chapter 8. Creating Command Pipelines
The designers of Unix created an operating system with a philosophy that remains valid to this day. The Unix designers established the following:
Everything is a file. Devices are represented as special files, as are networking connections and plain old normal files.
Each process runs in an environment. This environment includes standard files for input, output, and errors.
Unix has many small commands, each of which was designed to perform one task and to do that task well. This saves on memory and processor usage. It also leads to a more elegant system.
These small commands were designed to accept input from the standard input file and send output to the standard output files.
You can combine these small commands into more complex commands by creating command pipelines.
This chapter delves into these concepts from the perspective of shell scripts. Because shell scripts were designed to call commands, the ability to create command pipelines, thereby making new, complex commands from the simple primitive commands, provides you with extraordinary power. (Be sure to laugh like a mad scientist here.)
This chapter covers how you can combine commands and redirect the standard input, output, and errors, as well as pipe commands together.
Working with Standard Input and Output
Every process on Unix or a Unix-like system is provided with three open files (usually called file descriptors). These files are the standard input, output, and error files. By default: ...
Get Beginning Shell Scripting 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.