# Gathering orphaned packages list echo "Gathering orphaned packages list..." orphaned_packages="$(pacman -Qtdq)" if [[ ! -z $orphaned_packages ]]; then echo "$orphaned_packages" | sudo pacman -Rns - else echo "No package to be removed." fi unset orphaned_packages