Created
June 30, 2019 10:18
-
-
Save jwoglom/7f03de0520b32625f6fa9bd2b3a7c8ff to your computer and use it in GitHub Desktop.
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
function single_replace { | |
python3 -c "import sys, re; print(re.sub(sys.argv[1], sys.argv[2], open(sys.argv[3]).read()))" "$@" | |
} | |
function multi_replace { | |
python3 -c "import sys, re; t=open(sys.argv[1]).read(); | |
for i in range(2, len(sys.argv)-1, 2): | |
t=re.sub(sys.argv[i], sys.argv[i+1], t) | |
print(t, end='')" "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment