Filter (Unix)

Filter (Unix)

In UNIX and UNIX-like operating systems, a filter is a program that gets most of its data from standard input (the main input stream) and writes its main results to standard output (the main output stream). UNIX filters are often used as elements of pipelines. The pipe operator ("|") on a command line signifies that the main output of the command to the left is passed as main input to the command on the right.

The classic filter would be grep, which at it simplest prints to its output any lines containing a character string. Here's an example: cut -d : -f 1 /etc/passwd | grep foo

This finds all registered users that have "foo" 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.

Here is a perl equivalent to the above, which prints the whole line from the passwd file: perl -ne 'print if m/^ [^:] *foo/' /etc/passwd

Or, to print only the username, without the rest of the line: perl -ane '$_ = shift @F; print "$_ " if /foo/' -F: /etc/passwd

Common UNIX filter programs are: cat, cut, grep, head, sort, uniq and tail. Programs like awk and sed can be used to build quite complex filters because they are fully programmable.

List of UNIX filter programs

* awk
* cat
* comm
* cut
* expand
* compress
* fold
*grep
*head
* nl
*perl
* pr
*sed
* sh
* sort
* split
* strings
*tail
* tac
*tee
* tr
*uniq
* wc

ee also

*Filter (software)
*http://wiki.debian.net/index.cgi?filter


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Filter (Unix) — Filter sind Befehle in Betriebssystemen, die Eingaben vom Gerät stdin aufnehmen, weiterverarbeiten und ihr Ergebnis auf das Gerät stdout schreiben. Der Begriff des Filters stammt ursprünglich vom Betriebssystem Unix, wurde aber von Microsoft im… …   Deutsch Wikipedia

  • Filter — may refer to: Chemistry, engineering and materials In chemistry, engineering, or household usage, a device to separate mixtures. See: * Filter (chemistry) * Water filter * Air filter * Oil filter * Pneumatic filter Optics and photography In… …   Wikipedia

  • Filter — (m., n., nach fr. filtrer, it. feltrare, „durchseihen“; ursprünglich „durch Filz laufen lassen“ zu germanisch *felt „Filz“) steht für: Geräte, Bauteile oder Baugruppen: Filter (Elektrotechnik), eine elektrische Schaltung, die bestimmte Frequenzen …   Deutsch Wikipedia

  • Filter (software) — A filter is a computer program to process a data stream. Some operating systems such as Unix are rich with filter programs. Even Windows has some simple filters built in to its command shell, most of which have significant enhancements relative… …   Wikipedia

  • Unix-Kommandos — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • UNIX-Kommandos — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix-Befehle — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix-Kommando — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix Kommandos — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix security — Unix security: maintaining a secure environment on Unix and Unix like operating systems is dependent on design concepts of these operating systems, but vigilance through user and administrative techniques is important to maintain security… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”