4. Files, Streams, and Pipes#
This chapter focuses on the Unix idea that text streams, files, and small composable utilities can solve large practical problems.
Streams: Follow data through standard input, output, and error.
Inspection: Choose commands that reveal enough of a file without overwhelming the terminal.
Filtering: Select complete lines with literal patterns and interpret no-match results.
Verification: Compare counts and saved stages with known input while keeping diagnostics visible.
Pipelines: Combine commands so each tool performs one clear step.
Chapter Video
How to Use Redirection and Pipelines in Bash (9:50) by Microsoft Developer
Hosted on YouTube; property of its original creator, embedded here for educational reference only.
Learning Objectives
By the end of this chapter, you will be able to:
Explain how the Unix data model treats files and streams.
Inspect text and binary data with standard command-line tools.
Inspect and count matching log records with literal grep patterns.
Trace input, output, and diagnostics through a basic pipeline.
Save and verify a result without overwriting its source.
Chapter Flow
Glossary
# |
Term |
Explanation |
|---|---|---|
1 |
Standard input |
The default input stream read by a command. |
2 |
Standard output |
The default stream where a command writes normal output. |
3 |
Standard error |
The stream where a command writes diagnostics and errors. |
4 |
Text stream |
A sequence of text data flowing into or out of a process. |
5 |
Pipeline |
A chain of commands connected so output from one becomes input to the next. |
6 |
Pipe |
The ` |
7 |
Redirection |
Shell syntax that sends input or output to files or other streams. |
8 |
|
A command that writes file contents to standard output. |
9 |
|
A pager for reading text interactively. |
10 |
|
A command that shows the beginning of a file or stream. |
11 |
|
A command that shows the end of a file or stream. |
12 |
|
A command that reports the likely type of a file. |
13 |
|
A command that counts lines, words, and bytes. |
14 |
|
A command that searches text for matching lines. |
15 |
|
A command that orders lines of text. |
16 |
|
A command that collapses or counts adjacent duplicate lines. |
17 |
File descriptor |
A process-local number identifying an open input/output resource. |
18 |
Literal match |
A search that treats the pattern as fixed text rather than a regular expression. |
Lecture Slides
Files, Streams, and Pipes slides