python script similar to cat

July 3rd, 2008 by webstersprodigy

This is a stupid script similar to cat.  Again, I am using it for windows.

#!/usr/bin/env python

import sys, os
readsize = 1024

#parts is a list of files to be concatinated
def concatfiles(parts):
  for filename in parts:
    fileobj = open(filename, 'rb')
    while 1:
      filebytes = fileobj.read(readsize)
      if not filebytes:
        break
      print filebytes
    fileobj.close()

if __name__ == '__main__':
  concatfiles(sys.argv[1:])

Tags:

Leave a Reply


No computers were harmed in the 0.252 seconds it took to produce this page.