Chapter 5
Streams of Text

Long ago, if you wanted output from a program, you had to write specific instructions into your code. If you wanted the program to take input from a keyboard, you had to write that code as well. This tightly coupled the program to the hardware on which it ran, making things pretty specialized and not easily portable. Unix introduced the concept of standard streams of data at the OS level, which meant that programs could write to these standard streams, and the OS would take care of the rest, either handling the input or displaying the output appropriately.

There are three standard streams you’ll encounter when working on the CLI on a Unix-based system:

  • Standard Output (stdout): Output from a program.
  • Standard Input (stdin): Input to a program.
  • Standard Error (stderr): Errors from a program.

When you start a program in the CLI, the standard input is connected to your terminal’s input (your keyboard), while the standard output and standard error streams are connected to your terminal’s output (the screen). However, you can change how these connections work. You can send the output to a log, discard the output entirely, or even send the output of one program to another program as its input stream. You can create basic or complex workflows using a handful of basic tools.

You’ve already seen a few of the concepts used in this chapter elsewhere in the book, but you’ll now dive a little deeper. You’ll start by reviewing how to redirect these streams, and then you’ll learn about programs specifically designed to process text on the command line.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.28.197