Created
August 3, 2018 14:07
-
-
Save sandcastle/e830e1dcd4488db323785ff419660e1b to your computer and use it in GitHub Desktop.
Replace text function for shell
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 text_replace() { | |
case "${OSTYPE}" in | |
darwin*) PLATFORM="OSX" ;; | |
linux*) PLATFORM="LINUX" ;; | |
bsd*) PLATFORM="BSD" ;; | |
*) PLATFORM="UNKNOWN" ;; | |
esac | |
if [[ "${PLATFORM}" == "OSX" || "${PLATFORM}" == "BSD" ]]; then | |
find $1 -type f -name $2 -exec sed -i "" "s/$3/$4/g" {} + | |
else | |
find $1 -type f -name $2 -exec sed -i "s/$3/$4/g" {} + | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment