0Pricing
DevOps Bootcamp · Lesson

Piping Commands (|)

Understand the power of pipes to connect commands, sending the output of one command as input to another for complex operations.

Piping Commands (|) is a free DevOps Bootcamp lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Connect Commands with Pipes

Welcome! In Linux, you often need to combine the power of several commands to get a specific result. This is where pipes come in handy.

A pipe allows you to send the output of one command directly as the input to another command. Think of it like a conveyor belt for data!

The Pipe Symbol '|'

The pipe symbol is a vertical bar: |. You place it between two commands.

  • The command on the left sends its standard output (what it normally prints to the screen).
  • The command on the right receives this output as its standard input.

It's a fundamental concept for efficient command-line work!

Your First Pipe: `ls | less`

Let's see a pipe in action. The ls -l /usr/bin command lists many files, often too many for one screen.

By piping its output to less, you can view it page by page. Try running this example:

ls -l /usr/bin | less

Filtering Output with `grep`

Pipes are excellent for filtering. The grep command searches for patterns in text. When combined with a pipe, it can filter the output of another command.

This command lists all files in the current directory and then filters to show only those ending with .txt:

ls | grep .txt

Counting Items with `wc`

The wc (word count) command can count lines, words, or characters. When used with a pipe, it counts from the piped input.

To count how many .txt files are in the current directory, you can chain ls, grep, and wc -l (count lines):

ls | grep .txt | wc -l

Chaining Multiple Commands

You're not limited to just two commands! You can chain many commands together with multiple pipes, creating powerful sequences.

Each pipe passes the output of the previous command to the next one in the chain:

ps aux | grep chrome | wc -l

Sorting Piped Output (`sort`)

The sort command arranges lines of text alphabetically or numerically. It's often used after a pipe to organize data.

This example lists files in /etc and sorts them in reverse alphabetical order, showing only the first 5 results:

ls /etc | sort -r | head -n 5

Finding Unique Lines (`uniq`)

The uniq command removes duplicate adjacent lines. It's most effective when used after sort, which brings identical lines together.

Let's sort a list of fruits and then find the unique ones:

echo -e "apple\nbanana\napple\norange" | sort | uniq

Pipes vs. I/O Redirection

Remember I/O redirection (>, >>, <) from the previous lesson?

  • Pipes (|): Connect the output of one command to the input of another command. This keeps data flowing between programs.
  • Redirection (>, <): Connects a command's input/output to a file. This saves data to disk or reads it from disk.

Both are powerful but serve different purposes.

Pipe Knowledge Check

You've learned how to connect commands using pipes. Let's test your understanding!

Recap: The Power of Pipes

Great job! You've mastered the basics of piping commands in Linux.

  • Pipes (|) connect the output of one command to the input of another.
  • They allow you to chain commands for powerful filtering, sorting, and processing tasks.
  • Pipes are distinct from I/O redirection, which connects commands to files.

Keep practicing with different commands and see how much you can achieve by combining them!

Frequently asked questions

Is the “Piping Commands (|)” lesson free?

Yes — the full text of “Piping Commands (|)” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Piping Commands (|)”?

Understand the power of pipes to connect commands, sending the output of one command as input to another for complex operations. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Piping Commands (|)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Managing Processes (ps, top, kill)
  2. Input/Output Redirection (>, >>, <)
  3. Piping Commands (|)
  4. Background Jobs & Job Control
← Back to DevOps Bootcamp