Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Search and replace in file with python 2.x
#!/usr/bin/env python
import fileinput
import re
import sys
file = fileinput.FileInput("/etc/ssh/sshd_config", inplace=True, backup=".bak")
for line in file:
line = re.sub(r".*Banner.*","Banner /etc/issue.net", line)
sys.stdout.write(line)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.