Created
June 22, 2018 22:46
-
-
Save lanbugs/1c872daaa9e5ce3b12b9e2f12ea44da8 to your computer and use it in GitHub Desktop.
Search and replace in file with python 2.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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