Skip to content

Instantly share code, notes, and snippets.

@yasuakiohama
Last active July 6, 2016 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasuakiohama/0905ff1b470ad21884a1631f605cf58b to your computer and use it in GitHub Desktop.
Save yasuakiohama/0905ff1b470ad21884a1631f605cf58b to your computer and use it in GitHub Desktop.
findUsedObject.sh
#!/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