Skip to content

Instantly share code, notes, and snippets.

@ashwanthkumar
Created December 29, 2016 10:15
Show Gist options
  • Save ashwanthkumar/18b16f3aae65547ea6a72439c08ab4e6 to your computer and use it in GitHub Desktop.
Save ashwanthkumar/18b16f3aae65547ea6a72439c08ab4e6 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
function find_and_replace_dirs_recursively {
FIND=$1
REPLACE=$2
ls -d */ | xargs -IDIR egrep -lRZ "$FIND" DIR | xargs -IFILE sed -i "" -e "s/${FIND}/${REPLACE}/g" FILE
}
function find_and_replace_files {
FIND=$1
REPLACE=$2
ls -p | grep -v / | xargs -IFILE sed -i "" -e "s/${FIND}/${REPLACE}/g" FILE
}
REPOS="docs.go.cd api.go.cd plugin-api.go.cd"
for REPO in ${REPOS}; do
pushd $REPO
find_and_replace_dirs_recursively 'docs\.go\.cd' 'docs\.gocd\.io'
find_and_replace_dirs_recursively 'developer\.go\.cd' 'developer\.gocd\.io'
find_and_replace_dirs_recursively 'api\.go\.cd' 'api\.gocd\.io'
find_and_replace_dirs_recursively 'www\.go\.cd' 'www\.gocd\.io'
## Fix the github repo urls
find_and_replace_dirs_recursively '\/gocd\/api\.gocd\.io' '\/gocd\/api\.go\.cd'
find_and_replace_dirs_recursively '\/gocd\/plugin-api\.gocd\.io' '\/gocd\/plugin-api\.go\.cd'
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment