From the course: Linux: Package Management for CentOS

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

RPM query formatting

RPM query formatting - Linux Tutorial

From the course: Linux: Package Management for CentOS

Start my 1-month free trial

RPM query formatting

- [Instructor] Querying the rpm database can be very powerful. If, however, we want to present the information in a certain format, we might want to change the fields that are returned. All packages have tags that we can show or hide. To get a list of all tags in the terminal type in rpm --querytags and hit enter. My CentOS installation lists nearly 190 different tags. You get to decide what you want printed on the screen just by choosing the tags. Type in clear to clear your screen. If I wanted to show the package name and version, but nothing else I could do: rpm -qa --queryformat "%{NAME} %{VERSION}\n". To use the tags, we need to surround them with a percent symbol and curly brackets. For this example, I'm querying all files in the database with the -qa option then I'm specifying a query format of name and version. Notice at the end of the line I have to include \n to insert a new line. If I don't, it will all end up on one line and be hard to read. Now hit enter. If you wanted to…

Contents