Skip to content

Instantly share code, notes, and snippets.

@mori-dev
Created January 18, 2012 02:18
rails-project-gem-grep-r
#!/bin/bash
(($#<1)) && { echo 'usage: rails-project-gem-grep-r "search_target"' >&2; exit 1; }
search_target=$1
while [ 1 ]; do
if [ -f 'Gemfile.lock' ]; then
bundle list |
awk '/\*/ {print $2}' |
xargs -n1 bundle show |
xargs -n1 grep -r $search_target
exit $?
fi
cd ..
if [ "$PWD" = "/" ]; then
echo 'fail' 1>&2
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment