[Tutor] Unix philosophy
Kalle Svensson
kalle at lysator.liu.se
Mon Nov 17 14:17:23 EST 2003
Hi!
[Guillermo Fernandez Castellanos]
> I was having a look at the UNIX philosophy and I readed that:
> "Make every program a filter
> This makes it easy to build a set of filter components into ``one
> big filter.'' Programs can communicate by explicitly reading and
> writing files; that is / much / more complex to manage, and requires
> a lot of disk I/O for interim output. A set of filters may pass data
> straight from memory buffer to memory buffer, avoiding disk
> altogether."
>
> I was wondering how I could be able to make my python programs work
> in a filter mode?
Basically, what you have to do is read input from stdin and write
output to stdout. That makes it possible to use it as a filter in a
pipeline like
grep something < file | python myprog.py | lp
or whatever. The "|" signs here connect the first program's stdout to
the second program's stdin.
Peace,
Kalle
--
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
More information about the Tutor
mailing list