Last active
July 6, 2016 15:32
-
-
Save yasuakiohama/0905ff1b470ad21884a1631f605cf58b to your computer and use it in GitHub Desktop.
findUsedObject.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/sh | |
#------------------------------------------------------------------------------------------------------ | |
if [ $# -ge 3 ]; then | |
echo "error" | |
exit 1 | |
elif [ $# -eq 0 ]; then | |
echo "error" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------------------------------ | |
name=$1 | |
type=$2 | |
#------------------------------------------------------------------------------------------------------ | |
IFS_BAK=$IFS | |
IFS=$'\n' | |
array=($(find . -name "*${name}*")) | |
IFS=$IFS_bak | |
#------------------------------------------------------------------------------------------------------ | |
for file in ${array[@]}; do | |
if [ `echo ${file} | grep meta` ] ; then | |
echo "${file}" | |
if [ $# -eq 1 ]; then | |
git grep -l `cat "${file}" | grep guid | cut -d ":" -f 2` | grep -v meta | |
elif [ $# -eq 2 ]; then | |
git grep -l `cat "${file}" | grep guid | cut -d ":" -f 2` | grep -v meta | grep "${type}" | |
fi | |
echo "" | |
fi | |
done | |
#------------------------------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment