Created
June 22, 2018 22:45
-
-
Save lanbugs/ee428978bf94eb92a97ca3fefddd3825 to your computer and use it in GitHub Desktop.
Search and replace in files with python3
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 python3 | |
import fileinput | |
import re | |
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) | |
print(line, end='') | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment