Pipes
All the commands we have looked at have printed their information to the screen, but this is often flexible.
A pipe is a connector between one command’s output and another’s input. Instead of sending its output to your terminal, using a pipe sends that output directly to another command as input.
Two of the commands we have looked at so far are ps
and grep
: the process lister and the string matcher. We can combine the two to find out which users are playing Nethack right now:
matthew@seymour:~$ ps aux | grep nethack
That creates a list of all the processes running right now and sends that list to the grep
command, which filters out all lines that do not contain the word nethack
. Ubuntu allows you to pipe as ...
Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth 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.