wiki:Linux/Ubuntu/FindAndRemoveMultiplePackagesAtOnce

Find and Remove Multiple Packages at Once

This is a simple shell command string that locates and removes a set of related packages in one go. It came about from wanting to remove all the EVMS packages I'd just tested when I couldn't recall all the names.

FIND="*evms*"; PKGLIST="$(dpkg-query -l "$FIND" | sed -n 's/^.[ih] *\([^ ]*\).*/\1/p' | while read PKG; \
 do echo " $PKG"; done)"; sudo apt-get remove $PKGLIST