Recursive sed find and replace text
Find and replace text in files recursively on Linux, macOS and
Windows Subsystem for Linux
with recursive_sed.sh
:
#!/usr/bin/env bash
#
# The quoted variables allow using backticks and other "nasty" characters in sed.
#
# usage:
# ./recursive_sed.sh pathtofiles yuck yay
#
# References:
# https://stackoverflow.com/a/1585810
# https://unix.stackexchange.com/a/128758
set -o errexit
set -o nounset
path=$1
old=$2
new=$3
echo "${old} => ${new}"
find $path -not -path '*/.git*' -type f -execdir sed -i 's/'"${old}"'/'"${new}"'/g' {} +