How do I write a unix filter in python? -


I want to write a program that reads stdin (unbuffered) and some trivial four-four-character stdout (unbuffered ) Writes changes. For example, suppose I want to remove all the letter x from stdin.

I do not know what you are saying by buffer in this context, but whatever you are asking for It is very simple to do ...

so_gen.py (can see a constant stream generator):

  import time importing system while importing : 'Abcdefx' for four: sys.stdout.write (char) sys.stdout.flush () time.sleep (0.1)  

so_filter.py (What are you asking for ):

  import while correct: char = sys.stdin.read (1) if not four: break if char! = 'X': sys.stdout.write (char) sys.stdout.flush ()  

Try to run Python so_gen.py | Python so_filter.py to see what it does.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -