1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/python import sys import re for fileName in sys.argv[1:]: f = open(fileName, 'r+') fileString = f.read() fileString = re.sub(r'[ ]+\n', r'\n', fileString) fileString = re.sub(r'\r', r'', fileString) f.seek(0) f.write(fileString) f.truncate(len(fileString))