Menu
Coddy logo textTech

What Is A Pipe

Part of the Fundamentals section of Coddy's Terminal journey — lesson 43 of 82.

Redirection lets you send output to files, but what if you want to send the output of one command directly into another command? That's where pipes come in.

A pipe connects the standard output of one command to the standard input of another using the | symbol. Instead of saving intermediate results to a file, data flows directly between commands.

cat names.txt | sort

This takes the output of cat names.txt and feeds it directly into sort. The sorted result appears on your screen without creating any temporary files.

Without pipes, you would need multiple steps:

cat names.txt > temp.txt
sort < temp.txt
rm temp.txt

The pipe accomplishes the same thing in a single, elegant command. Think of it as connecting commands like sections of a pipeline — data enters one end and flows through each command in sequence until it reaches the final output.

challenge icon

Challenge

Easy

Use a pipe to read the contents of fruits.txt and sort them alphabetically in a single command.

Run a command that:

  • Uses cat to read fruits.txt
  • Pipes the output to sort using the | symbol

Hint: The format is cat filename | sort. The output of cat flows directly into sort without needing any intermediate files.

Cheat sheet

A pipe connects the standard output of one command to the standard input of another using the | symbol:

cat names.txt | sort

This takes the output of cat names.txt and feeds it directly into sort, eliminating the need for temporary files.

Without pipes, you would need multiple steps:

cat names.txt > temp.txt
sort < temp.txt
rm temp.txt

Data flows through each command in sequence like sections of a pipeline.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals