Skip to content

Instantly share code, notes, and snippets.

@newmen
Last active January 2, 2016 05:29
Show Gist options
  • Save newmen/8257737 to your computer and use it in GitHub Desktop.
Save newmen/8257737 to your computer and use it in GitHub Desktop.
This little code is more useful if you doesn't want keep old versions of installed gems
`gem list`.split("\n").each do |line|
next if line == ''
name = line.scan(/^\S+/).first
versions = line.scan(/\(([^\)]+)\)/).first.first.split(', ')
versions.shift
unless versions.empty?
versions.each do |version|
`gem uninstall #{name} -v #{version} --force`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment