Redirecting output

Before we go any further, we should have a discussion about redirecting output. One of the many great things about Linux is that it's made up of many utilities, each doing one thing and doing that one thing well. These smaller commands and utilities become even more efficient because we can take the output of one command and redirect it into the input of another command. Take this command as an example:

cat /var/log/syslog | grep apache2

Here, we're using the cat command to print the contents of the system log stored at /var/log/syslog. Using the pipe symbol, we're redirecting the output of that command and feeding it into grep, which is looking for the string apache2. When used together, we're able to fetch lines from ...

Get Mastering Ubuntu Server - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.