Skip to content

Instantly share code, notes, and snippets.

@nateflink
Last active September 21, 2022 12:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nateflink/9056302 to your computer and use it in GitHub Desktop.
Save nateflink/9056302 to your computer and use it in GitHub Desktop.
#!/bin/bash
#By Nate Flink
#Invoke on the terminal like this
#curl -s https://gist.github.com/nateflink/9056302/raw/findreplaceosx.sh | bash -s "find-a-url.com" "replace-a-url.com"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ./$0 [find string] [replace string]"
exit 1
fi
FIND=$1
REPLACE=$2
#needed for byte sequence error in ascii to utf conversion on OSX
export LC_CTYPE=C;
export LANG=C;
#sed -i "" is needed by the osx version of sed (instead of sed -i)
find . -type f -exec sed -i "" "s|${FIND}|${REPLACE}|g" {} +
exit 0
@mani-coder
Copy link

thanks! you saved lot of my time today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment