Last active
December 3, 2020 16:16
-
-
Save chchrn/8ed1cf3ee02825310f23adf47a9d8310 to your computer and use it in GitHub Desktop.
changeImportToAnglesForLib.sh
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
#!/bin/bash | |
# sample use: | |
thisScriptName=`basename "$0"` | |
if [[ $# -ne 3 ]]; then | |
echo "$thisScriptName <LIB PATH> <CODE PATH> <LIB NAME> \n" | |
echo "$thisScriptName ./myProject/src/Frameworks/ ./myProject/src Wlib \n" | |
exit 2 | |
fi | |
libPath=$1 | |
codePath=$2 | |
libName=$3 | |
libFileNames=( $(find $libPath -name "*.h" | sed 's!.*/!!') ) | |
for libFileName in "${libFileNames[@]}" | |
do | |
importStr="#import \"${libFileName}\"" | |
newImportStr="#import <${libName}\/${libFileName}>" | |
echo "Find imports of ${importStr}" | |
#files=( $(grep -include=\*.{h,m} -rl '$codePath' -e '#import "$fileName"') ) | |
files=( $(grep --exclude-dir=$libPath -rl "${codePath}" -e "${importStr}")) | |
echo $files | |
for codeFilePath in "${files[@]}" | |
do | |
sed -i '' "s/${importStr}/${newImportStr}/g" $codeFilePath | |
echo "Changed $codeFilePath" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment