.. include:: ../header.txt .. _filtering: Filtering Data =========================== :title:`Linux for Programmers and Users`, Section 4.2 - 4.3. We use commands that filter data to select only the portion of data that we wish to view or operate on. Filtering commands are usually run with either a filename as a command line argument or they read data from `stdin`, usually from a pipe. Some programs, such as :ref:`awk` and :ref:`sed`, which are really programming languages, can filter data horizontally, vertically or inline, while other tools filter data either horizontally or vertically. ------------------------------- .. centered:: The Pipe (`|`) .. index:: pipe, | A fundamental concept that will be used in filtering data and for the rest of the semester is that of the **pipe**. A pipe is a facility of the shell that makes it very to chain together multiple commands. A is called upon with the vertical bar character (**\ |**). When used between two Unix commands, it means that output from the first command should become the input to the second command. For example, to count how many files underneath a directory have been modified in the last day, the :command:`find` and :command:`wc` commands may be used along with a pipe (:ref:`find`, :ref:`wc`). The :command:`find` command will list the modified files and :command:`wc` can count them:: find . -type f -mtime -1 | wc -l ------------------------------- **Contents** .. toctree:: :maxdepth: 2 filtHoriz filtVert inline awk