HOME

TheInfoList



OR:

A filter is a computer program or subroutine to process a stream, producing another stream. While a single filter can be used individually, they are frequently strung together to form a pipeline. Some operating systems such as Unix are rich with filter programs.
Windows 7 Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was Software release life cycle#Release to manufacturing (RTM), released to manufacturing on July 22, 2009, and became generally available on October 22, ...
and later are also rich with filters, as they include Windows PowerShell. In comparison, however, few filters are built into cmd.exe (the original command-line interface of Windows), most of which have significant enhancements relative to the similar filter commands that were available in
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
.
OS X macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lap ...
includes filters from its underlying Unix base but also has Automator, which allows filters (known as "Actions") to be strung together to form a pipeline.


Unix

In Unix and Unix-like operating systems, a filter is a program that gets most of its data from its
standard input In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdi ...
(the main input stream) and writes its main results to its
standard output In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdi ...
(the main output stream). Auxiliary input may come from command line flags or configuration files, while auxiliary output may go to
standard error The standard error (SE) of a statistic (usually an estimate of a parameter) is the standard deviation of its sampling distribution or an estimate of that standard deviation. If the statistic is the sample mean, it is called the standard error of ...
. The command syntax for getting data from a device or file other than standard input is the input operator (<). Similarly, to send data to a device or file other than standard output is the output operator (>). To append data lines to an existing output file, one can use the append operator (>>). Filters may be strung together into a pipeline with the pipe operator (", "). This operator signifies that the main output of the command to the left is passed as main input to the command on the right. The
Unix philosophy The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Uni ...
encourages combining small, discrete tools to accomplish larger tasks. The classic filter in Unix is Ken Thompson's , which Doug McIlroy cites as what "ingrained the tools outlook irrevocably" in the operating system, with later tools imitating it. at its simplest prints any lines containing a character string to its output. The following is an example: cut -d : -f 1 /etc/passwd , grep foo This finds all registered users that have "
foo The terms foobar (), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. - Etymology of "Foo" They have been used to name entities such as variables, fu ...
" as part of their username by using the cut command to take the first field (username) of each line of the Unix system password file and passing them all as input to grep, which searches its input for lines containing the character string "foo" and prints them on its output. Common Unix filter programs are:
cat The cat (''Felis catus'') is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is commonly referred to as the domestic cat or house cat to distinguish it from the wild members of ...
, cut, grep, head, sort, tail, and
uniq uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text. Overview The command is a ...
. Programs like
awk AWK (''awk'') is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems. The AWK lan ...
and sed can be used to build quite complex filters because they are fully programmable. Unix filters can also be used by
Data scientists Data science is an interdisciplinary field that uses scientific methods, processes, algorithms and systems to extract or extrapolate knowledge and insights from noisy, structured and unstructured data, and apply knowledge from data across a bro ...
to get a quick overview about a file based dataset.


List of Unix filter programs

*
awk AWK (''awk'') is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems. The AWK lan ...
*
cat The cat (''Felis catus'') is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is commonly referred to as the domestic cat or house cat to distinguish it from the wild members of ...
*
comm The command in the Unix family of computer operating systems is a utility that is used to compare two files for common and distinct lines. is specified in the POSIX standard. It has been widely available on Unix-like operating systems s ...
*
compress compress is a Unix shell compression program based on the LZW compression algorithm. Compared to more modern compression utilities such as gzip and bzip2, compress performs faster and with less memory usage, at the cost of a significantly l ...
* cut * expand * fold * grep * head * nl * paste * perl * pr * sed * sh * sort *
split Split(s) or The Split may refer to: Places * Split, Croatia, the largest coastal city in Croatia * Split Island, Canada, an island in the Hudson Bay * Split Island, Falkland Islands * Split Island, Fiji, better known as Hạfliua Arts, enterta ...
* strings *
tac TAC, or tac, may refer to: People * Pablo Tac, US scholar * Pham Cong Tac, a leader of the Cao Dai religion Places * Tác, a village in Fejér County, Hungary Organisations * TAC (building automation), a Swedish building automation company * T ...
* tail *
tee A tee is a stand used in sport to support and elevate a stationary ball prior to striking with a foot, club or bat. Tees are used extensively in golf, tee-ball, baseball, American football, and rugby. Etymology The word tee is derived from the ...
* tr *
uniq uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text. Overview The command is a ...
* wc *
zcat gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and in ...


DOS

Two standard filters from the early days of DOS-based computers are find and sort. Examples: find "keyword" < ''inputfilename'' > ''outputfilename'' sort "keyword" < ''inputfilename'' > ''outputfilename'' find /v "keyword" < ''inputfilename'' , sort > ''outputfilename'' Such filters may be used in batch files (*.bat, *.cmd etc.). For use in the same
command shell In computing, a shell is a computer program that exposes an operating system's services to a human user or other programs. In general, operating system shells use either a command-line interface (CLI) or graphical user interface (GUI), dependin ...
environment, there are many more filters available than those built into Windows. Some of these are
freeware Freeware is software, most often proprietary, that is distributed at no monetary cost to the end user. There is no agreed-upon set of rights, license, or EULA that defines ''freeware'' unambiguously; every publisher defines its own rules for the ...
, some
shareware Shareware is a type of proprietary software that is initially shared by the owner for trial use at little or no cost. Often the software has limited functionality or incomplete documentation until the user sends payment to the software developer ...
and some are commercial programs. A number of these mimic the function and features of the filters in Unix. Some filtering programs have a graphical user interface (GUI) to enable users to design a customized filter to suit their special
data processing Data processing is the collection and manipulation of digital data to produce meaningful information. Data processing is a form of ''information processing'', which is the modification (processing) of information in any manner detectable by a ...
and/or data mining requirements.


Windows

Windows Command Prompt Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows (Windows NT family and Windows CE family), and ReactOS operating systems. On Windows CE .NET 4.2, Win ...
inherited MS-DOS commands, improved some and added a few. For example,
Windows Server 2003 Windows Server 2003 is the sixth version of Windows Server operating system produced by Microsoft. It is part of the Windows NT family of operating systems and was released to manufacturing on March 28, 2003 and generally available on April 24, ...
features six command-line filters for modifying
Active Directory Active Directory (AD) is a directory service developed by Microsoft for Windows domain networks. It is included in most Windows Server operating systems as a set of processes and services. Initially, Active Directory was used only for centralize ...
that can be chained by piping: DSAdd, DSGet, DSMod, DSMove, DSRm and DSQuery. Windows PowerShell adds an entire host of filters known as "cmdlets" which can be chained together with a pipe, except a few simple ones, e.g. Clear-Screen. The following example gets a list of files in the C:\Windows folder, gets the size of each and sorts the size in ascending order. It shows how three filters (Get-ChildItem, ForEach-Object and Sort-Object) are chained with pipes. Get-ChildItem C:\Windows , ForEach-Object , Sort-Object -Ascending


References

{{Reflist


External links

* http://www.webopedia.com/TERM/f/filter.html Software design patterns Programming paradigms Operating system technology