Using Filters

In UNIX, filters are designed to accept input, process the data, and write the results to standard output. Think of a filter as a mechanical filter that filters data flowing through it. Using a filter, you can select which data to allow through the filter. grep is classified as a filter. Earlier in this chapter, I described how to use grep to search for a string in a text file and to display the lines containing that string. Now I’ll describe how to use grep to filter data going to standard output.

The ls –l /usr/bin command displays the following output:

 -r-xr-xr-x 1 root bin 21096 Nov 8 2001 acctcom -r-xr-xr-x 40 root bin 5420 Nov 8 2001 adb -r-xr-xr-x 1 root bin 10256 Nov 8 2001 addbib -r-s--x--x 1 root sys 350748 Nov 5 ...

Get Inside Solaris™ 9 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.