Back to DevOps Series
Detailed explanation of Pipe (|) operator:

Detailed explanation of Pipe (|) operator:

Pipe (|) connects two commands so that the output (stdout) of the first command becomes the input (stdin) of the second command.
Think of it like a water pipe:
Loading...
Instead of water flowing through a pipe, data flows through it.

Real example

Suppose you have a file students.txt:
Loading...
Without a pipe:
Loading...
Output:
Loading...
Now use a pipe:
Loading...
What happens?
  1. cat students.txt prints all the lines.
  1. The pipe | catches that output.
  1. head -n 2 receives it as input and prints only the first 2 lines.
Output:
Loading...

Another example

Loading...
  • ls → lists all files.
  • | → sends that list to the next command.
  • wc -l → counts the number of lines.
If there are 15 files:
Loading...

Pipe in Linux terms

  • Stdout (Standard Output) of the first command → Stdin (Standard Input) of the second command.
Loading...

One-line definition for notes

Pipe (|) is a Linux operator that passes the standard output (stdout) of one command as the standard input (stdin) to another command, allowing multiple commands to work together.