From: Oleg Broytman Date: Tue, 6 Mar 2018 08:42:39 +0000 (+0300) Subject: Remove bin/replace: Use `sed -i` instead X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=fb9ca1725eeda567c971968f2a89914403b0e748;p=dotfiles.git Remove bin/replace: Use `sed -i` instead --- diff --git a/bin/replace b/bin/replace deleted file mode 100755 index 8ff7124..0000000 --- a/bin/replace +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env python - -import sys - -if len(sys.argv) < 4: - sys.stderr.write("Usage: %s [-i] from_re to_re file....\n" % sys.argv[0]) - sys.exit(1) - -import re -if sys.argv[1] == '-i': - search = re.compile(sys.argv[2], re.IGNORECASE) - replace = sys.argv[3] - start = 4 -else: - search = re.compile(sys.argv[1]) - replace = sys.argv[2] - start = 3 - -from fileinput import FileInput -files = FileInput(sys.argv[start:], inplace=1) - -for line in files: - line = search.sub(replace, line) - sys.stdout.write(line) - -files.close()