Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to know about the "filter-command" which are available in Unix. I am confused regarding this:

  1. What is the purpose of "Filter-Command" ?
  2. Which are the Filter-commands available in Unix?

I have read some books/articles on web, in some books i found few filter commands and in some books i found some other.

share|improve this question
1  
Is this a question from some kind of exam or what is the context? –  echox Sep 10 '10 at 10:17
    
@echox no it was not for any exam...but i just wants a list of Filter commands which are being used in shell-script because i was confused about the total Filter commands...in some books i found some and in another i found some other –  Paresh Mayani Sep 11 '10 at 5:02
1  
you need to work on your English a bit. –  delete Sep 13 '10 at 4:05

2 Answers 2

up vote 6 down vote accepted

I'm not sure what you're asking without context. "Traditional" Unix tools read from standard input and write to standard output, so you can chain them together using a pipe, which is the | command:

 ls | grep "banana" | more

Things which read from standard input and write to standard output are filters.

There is an article here: http://en.wikipedia.org/wiki/Filter_(Unix)

share|improve this answer
    
ya exactly what i was looking for....i just wants a list of Filter commands which are being used in shell-script becoz i was confused about the total Filter commands...in some books i found some and in another i found some other..but this link provides All filter commands...thanx –  Paresh Mayani Sep 11 '10 at 5:01

A filter command is almost any command line program on UNIX, really.

Every program that can read from STDINand output to STDOUT can be used as filter.

There are exceptions, though. One such exception is cpio, which takes a list of files from STDIN to create an archive on output.

There are some commands, that seem not to be able to read from STDIN, though you should check wether those commands use - as file parameter to read from STDIN or write to STDOUT, like cat:

$ cat f - g

Output f’s contents, then standard input, then g’s contents.

But even when your program does not use that, you can still usually force a program to act as a filter:

For instance take wget and you want to make that program output to STDOUT:

$ wget -O /dev/stdout http://stackoverflow.com/ | less

i.e.: You can use /dev/stdin, /dev/stdout, and /dev/stderr, as files to force a program to read, or output into the standard-IO descriptors.

Another side note: The length of your pipe, can be as long as you wish, so you can pipe from one program to another, basically making it a long chain of filters:

$ cat file | xz | ccrypt &>/dev/null
share|improve this answer
1  
The last example doesn't make too much sense, I give you that. It's just used as a valid example. –  polemon Sep 10 '10 at 19:15
    
+1, the last example is kinda like goverments... a lot of effort and boha that goes nowhere... –  Stefan Sep 14 '10 at 7:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.