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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -