This was the dilemma I found myself in today. I wanted to remove all of the Gnome stuff from my FreeBSD installation in order to make a clean start by reinstalling it all over again.
However, what's a poor soul to do when 'pkg_info | grep -i gnome | wc -l
' results in a long list of packages (36) that all need to be removed safely first?
# pkg_info | awk '/gnome/ { print $1; system("pkg_delete " $1); }'
That's just one possible way of achieving this, maybe not the best but it works anyway.