Skip to content

Instantly share code, notes, and snippets.

@mbarton
Created August 6, 2014 14:59
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 mbarton/941740f82a7b2f2582b1 to your computer and use it in GitHub Desktop.
Save mbarton/941740f82a7b2f2582b1 to your computer and use it in GitHub Desktop.
Make all logs in this directory readable
#!/usr/bin/python
import glob
for log in glob.glob("**/*.log"):
f = open(log, "r")
mod_lines = []
for line in f:
split_line = line.split(" ")
mod_lines.append("%s %s %s" % (split_line[0], split_line[1], " ".join(split_line[4:])))
f.close()
f = open(log, "w")
for line in mod_lines:
f.write(line)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment