Shell Redirection and Pipelines

Master the power of shell redirection and pipelines in Linux. Learn to redirect standard input, output, and error streams, chain commands together using pipes, manage command history, and process text data with sort and uniq. This module teaches you how to combine simple commands into powerful data processing workflows.

DevOps EngineerLinuxDevOps

Introduction

This beginner course explains how data moves between Linux commands, the terminal, and files. Through six guided labs and a short final challenge, you will separate normal output from errors, redirect streams, build pipelines, reuse command history, summarize text, and create temporary command aliases.

The exercises combine small tools into observable workflows. The final log-analysis task turns a raw list of IP addresses into a counted, numerically sorted report using one pipeline and output redirection.

What You Will Learn

  • Distinguish standard output from standard error in successful, failing, and mixed commands
  • Overwrite or append command output to files with > and >>
  • Capture error messages separately with 2>
  • Connect commands with | so one command’s output becomes another command’s input
  • Inspect, repeat, and reverse-search command history with history, !!, and Ctrl+R
  • Sort text, collapse adjacent duplicates, and count occurrences with sort and uniq -c
  • Create, inspect, use, and remove temporary shell aliases
  • Build and save a pipeline that ranks repeated IP addresses numerically

Who This Course Is For

This course is for Linux beginners who can run commands and inspect text files and now want to compose repeatable command-line workflows. It is useful for aspiring DevOps practitioners, developers, and system administrators working with logs and textual command output.

Prerequisites: Basic terminal navigation and familiarity with commands such as ls, cat, grep, and wc; no shell-scripting experience is required.

Learning environment: A provided LabEx Linux terminal with prepared text and log files. Redirection, history, aliases, and pipeline exercises operate inside the labex user’s training workspace.

Frequently Asked Questions

How much of the course is guided?

Six labs provide step-by-step practice. The seventh and final unit is a two-step challenge where you count repeated IP addresses with sort | uniq -c, add numeric sorting, and redirect the result to ip_report.txt.

Does the course cover every form of shell redirection?

No. It practices standard-output overwrite and append with > and >>, plus separate error capture with 2>. It does not exercise <, 2>&1, here-documents, or tee.

Are the aliases permanent?

No. You create an ll alias in the current shell, inspect and run it, then remove it with unalias. Editing shell startup files for persistent aliases is outside this module.

Will > overwrite existing data?

Yes. A dedicated exercise demonstrates that > replaces a file’s contents, while >> appends. All examples use prepared files in the training workspace.

Teacher

labby
Labby
Labby is the LabEx teacher.