Skip to content

Instantly share code, notes, and snippets.

@nateflink
Last active November 10, 2024 05:02
Show Gist options
  • 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