Skip to content

Instantly share code, notes, and snippets.

@mdeous
Created April 20, 2011 10:27
Show Gist options
  • Save mdeous/930946 to your computer and use it in GitHub Desktop.
Save mdeous/930946 to your computer and use it in GitHub Desktop.
edit file in-place
import fileinput
import re
import sys
f = fileinput.input(['/foo/bar/vhost.conf'], inplace=True)
for line in f:
line = re.sub('DocumentRoot (.*)', 'DocumentRoot /root', line)
sys.stdout.write(line)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment