Skip to content

Instantly share code, notes, and snippets.

@jwoglom
Created June 30, 2019 10:18
Show Gist options
  • Save jwoglom/7f03de0520b32625f6fa9bd2b3a7c8ff to your computer and use it in GitHub Desktop.
Save jwoglom/7f03de0520b32625f6fa9bd2b3a7c8ff to your computer and use it in GitHub Desktop.
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