Linuxlab

Pipes in Linux: | and the sort, uniq, cut filters

Updated July 3, 2026

A pipe joins commands with | so the output of one becomes the input of the next.

Common cases

grep 404 access.log | wc -l                # how many 404 lines
cut -d' ' -f1 access.log | sort | uniq -c   # frequency by the first field
... | sort -rn                             # numeric sort, descending
ps aux | grep nginx | grep -v grep         # filter the process list

How it works: small commands, one job each

The Unix idea: each command does one job, reads from standard input and writes to standard output. | joins them: the kernel feeds the left command's output into the right command's input without touching the disk. The classic filters: grep selects lines, cut slices columns, sort orders, uniq -c counts adjacent repeats (so it almost always follows sort), wc -l counts lines. From these blocks you build log analysis on one line.

Used in

You need this in the lesson Streams and pipelines. The theory is the chapter Streams, redirection, pipelines.

See also

Redirection > and >>, The grep command.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.