query and downgrade selected packages based on version or repository

If you have worked on rpm based distro then you know how difficult it is to downgrade packages. And unluckily I upgraded some packages to fc12 and was still on FC11. Completely my mistake while doing some R&D. Anyway to downgrade I had to device some mechanism and here it is:

rpm -qa –qf \”%-30{NAME}%-20{RELEASE}\\n\” |grep fc12 |awk \'{print $1}\’|tr \’\\n\’ \’ \’ >downgrade

yum downgrade `cat downgrade`