Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
changeImportToAnglesForLib.sh
#!/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