This command worked for me after changed directory to /var/lib/pacman/local:
ls | sort | awk -v re='(.*)-[^-]*-[^-]*$''match($0, re, a) { if (!(a[1] in p)){p[a[1]]} else {print} }' | xargs sudo rm -rf
This command worked for me after changed directory to /var/lib/pacman/local:
ls | sort | awk -v re='(.*)-[^-]*-[^-]*$''match($0, re, a) { if (!(a[1] in p)){p[a[1]]} else {print} }' | xargs sudo rm -rf