Getting RPM names only

I can’t remember where I found this on google, but it’s something I’ll use a lot. If I want to just get the names of rpms installed on a machine, use this:

rpm -qa --qf " %{name}\n"|sort|uniq > list.rpms