Skip to content

Instantly share code, notes, and snippets.

@yunghoy
Created August 12, 2016 13:44
Show Gist options
  • Save yunghoy/e552495e55bd69024c3a3d961334811d to your computer and use it in GitHub Desktop.
Save yunghoy/e552495e55bd69024c3a3d961334811d to your computer and use it in GitHub Desktop.
I hate a simplest job such as substituting a word for another in various files
SOURCEDIR=utils
TARGETDIR=util
pushd be > /dev/null
SERVICES="$(ls -d *-island)"
popd > /dev/null
for SERVICE in ${SERVICES}; do
pushd be/${SERVICE}/src > /dev/null
if [ -d SOURCEDIR ]; then
echo "--------------------------------------------------"
echo "Modifying the island: ${SERVICE}"
# type your command
mkdir ${TARGETDIR}
cp ${SOURCEDIR}/*.ts ${TARGETDIR}
rm -rf ${SOURCEDIR}
grep -rl "\/utils\/" | xargs sed -i 's/\/utils\//\/util\//g'
grep -rl "\/utils" | xargs sed -i 's/\/utils/\/util\//g'
grep -rl "utils\/" | xargs sed -i 's/utils\//\/util\//g'
# end of your command
fi
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment