Skip to content

Instantly share code, notes, and snippets.

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/", line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment