How Does Unix Pipeline (Brian Kernighan) - Computerphile Work?

Imagine you're helping to sort toys in your room, and each friend does a part of the job, that’s how Unix pipelines work!

A pipeline is like when you pass something from one person to another, and each person changes it just a little before passing it on. In Unix, commands are like friends who help with sorting.

How the toys (data) move

Let's say you have a big pile of toys, and your first friend, ls, lists all the toys so you know what’s there. Then another friend, grep, picks out only the red toys for you. Finally, a third friend, sort, arranges them in order by name.

So instead of doing everything at once, each part of the job is done step by step, and each step gives its result to the next one. It’s like passing your toy list from one friend to another until it's all neat and tidy!

This makes things easier because you don’t have to do the whole job at once, just a little bit at a time!

Take the quiz →

Examples

  1. Using a simple Unix pipeline to sort and count words from a text file
  2. Filtering lines in a file using the 'grep' command
  3. Combining two commands with a pipe symbol

Ask a question

See also

Discussion

Recent activity

Categories: Science · Unix· Pipeline· Computerphile