#!/bin/sh
sudo dpkg --purge `dpkg -l | awk '/^rc/{print $2;}' `

#!/bin/sh
# sudo dpkg --purge `dpkg -l | awk '/^rc/{print $2;}' `
dpkg -l | awk '/^rc/{print $2;}' | xargs -r sudo dpkg --purge

Use xargs -r to prevent no 'rc' packages
Use xargs -r to prevent no 'rc' packages
