Created
July 1, 2018 08:15
-
-
Save sandcastle/985cc018c707c2a3e0f1191671a80514 to your computer and use it in GitHub Desktop.
Cross platform text replacement recursively in a directory
This file contains hidden or 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 artifacts/ -type f -name "*.yml" -exec sed -i "" "s/$1/$2/g" {} + | |
| else | |
| find artifacts/ -type f -name "*.yml" -exec sed -i "s/$1/$2/g" {} + | |
| fi | |
| } | |
| text_replace "BUILD_TAG" "master-2kl3e7qp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment