Skip to content

Instantly share code, notes, and snippets.

@mori-dev
Created January 18, 2012 02:18
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 mori-dev/1630427 to your computer and use it in GitHub Desktop.
Save mori-dev/1630427 to your computer and use it in GitHub Desktop.
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