public
Created

  • Download Gist
remove_gem.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Note: I'm assuming GNU sed, this would need tweaking to run on OSX
# which I'm not inclined to research/test right now.
 
cat > Gemfile.example <<EOF
gem "awesome"
gem "lame"
EOF
 
echo -e "\nBefore:"
cat Gemfile.example
 
 
sed -i '/gem "lame"/d' Gemfile.example
 
 
echo -e "\nAfter"
cat Gemfile.example
 
 
# Or if you prefer generalized and reusable
remove_gem() {
sed -i -r "/gem\s+('|\")$1\1/d" "${2:-Gemfile}"
}
 
remove_gem lame Gemfile.example

I believe the OS X version requires an extension parameter supplied to -i (.bak or similar)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.