A slighest different version, skipping the cut step, taking advantage of the '--no-version' option:
gem list --no-version |xargs gem uninstall -ax
Since you are removing everything, I don't see the need for the 'I' option. Whenever the gem is removed, it's fine.