Skip to content

Instantly share code, notes, and snippets.

@astrograzl
Created March 8, 2018 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrograzl/57d60ff9dc281c43cb61724db16959a6 to your computer and use it in GitHub Desktop.
Save astrograzl/57d60ff9dc281c43cb61724db16959a6 to your computer and use it in GitHub Desktop.
End of Line
#!python3
# coding: utf-8
"""Trim white space from end of line."""
import sys
if len(sys.argv) < 2:
sys.exit("Usage: eol.py FILENAME[S]")
for filename in sys.argv[1:]:
try:
with open(filename, "r") as finp:
lines = finp.readlines()
except Exception as err:
print(err)
else:
with open(filename, "w") as fout:
for line in lines:
fout.write(line.rstrip()+"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment