Google News
logo
Unix - Interview Questions
Explain the term filter.
A filter is described as a program, which takes input from the standard input, and displays results to the standard output by performing some actions on it.

Standard input could be text typed on the keyboard, input from other files, or output of other files serving as input. Standard output is by default the display screen.

The most popular example of Unix filter id is the grep command. This program look for a certain pattern in a file or list of files and only those lines are displayed on the output screen which contains the given pattern.

Syntax : $grep pattern file(s)

Some of the options that are used along with grepping command are enlisted below :

-v : prints a line that does not match the pattern.
-n : print matched line and line number.
-l : print file names with matching lines.
-c : prints only count the matching lines.
-i : matches either uppercase or lowercase.
Advertisement