Here is another simple example:
$ ls -s | sort -n
In this case, ls -s
would normally print a listing of the current
directory on the terminal, preceding each file with its size. But instead
we've piped the output into sort -n
, which sorts the output numerically.
This is a really useful way to find large files in your home directory!
The following examples are more complex, but they demonstrate the power that
can be harnessed using pipes. We're going to throw out some commands we
haven't covered yet, but don't let that slow you down. Concentrate instead on
understanding how pipes work so you can employ them in your daily Linux tasks.