Chapter 2. Standard Output
No software is worth anything if there is no output of some sort, but I/O has long been one of the nastier areas of computing. If you’re ancient, you remember the days when most of the work involved in running a program was setting up the program’s input and output. Some of the problems have gone away; for example, you no longer need to get operators to mount tapes on a tape drive (at least, not on any laptop or desktop system that we’ve seen!). But many of the difficulties are still with us.
One problem is that there are many different types of output. Writing something on the screen is different from writing something in a file—at least, it sure seems different. Writing something in a file also seems different from writing it on a tape, or in flash memory, or on some other kind of device. And what if you want the output from one program to go directly into another program? Should software developers be tasked with writing code to handle all sorts of output devices, even ones that haven’t been invented yet? That’s certainly inconvenient. Should users have to know how to connect the programs they want to run to different kinds of devices? That’s not a very good idea, either.
One of the most important ideas behind the Unix operating system was that everything looked like a file (an ordered sequence of bytes). The operating system was responsible for this magic. It didn’t matter whether you were writing to a file on the disk, the terminal, a tape drive, ...
Get bash Cookbook, 2nd Edition 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.