What Are Pipes in the Linux Terminal

How to connect one command's output to another's input with no intermediate files.

Intermediate 1 min read Published on 2026 By Equipo SolucionaPC

A pipe (|) connects one command's output directly to another's input — without saving anything to an intermediate file.

Simple example

ls -l | grep ".txt"

ls -l lists the files; instead of showing them all on screen, that list gets "piped" to grep, which filters only the lines containing ".txt". The final result is only what interests you, not everything in between.

Chaining several pipes

cat file.log | grep "error" | wc -l

Shows a file's content, filters only the lines with "error", and counts how many there are in total — three steps chained on a single line, with no temporary files.

Tip: think of each pipe as a conveyor belt between two machines — what comes out of one goes straight into the next, without having to pass through an intermediate tray (a saved file).

Difference from redirection (>)

A pipe (|) connects one command with ANOTHER command. Redirection (>) saves a command's output to a FILE. They're related but different concepts — easy to mix up at first.

Frequently asked questions

Can I chain more than two commands with pipes?

Yes, there's no practical limit — you can chain as many commands as you need, each processing the previous one's output.

Is a pipe the same as saving the output to a file?

No, they're different concepts. A pipe (|) connects one command directly with another; redirection (>) saves the output to a file on disk.

Share: