Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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