From 6a0dd29d364844b24f1b6dc4beb2e20b5a634ac2 Mon Sep 17 00:00:00 2001 From: pux Date: Sat, 7 Jan 2023 14:17:56 +0100 Subject: update from pub-docs --- data/pyreplace.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 data/pyreplace.py (limited to 'data/pyreplace.py') diff --git a/data/pyreplace.py b/data/pyreplace.py new file mode 100755 index 0000000..71e970e --- /dev/null +++ b/data/pyreplace.py @@ -0,0 +1,15 @@ +#!/bin/env python3 + +import sys + +if __name__ == '__main__': + if len(sys.argv) < 3: + sys.exit() + + data = [] + with open(sys.argv[3], 'r+') as file: + data = file.read() + data = data.replace(sys.argv[1], sys.argv[2]) + file.close() + with open(sys.argv[3], 'w') as filew: + filew.write(data) -- cgit v1.2.2-1-g5e49