Product SiteDocumentation Site

4.2.13. Formatting Arrays

Many of the header entries are arrays, so the header tags can hold more than one item. For example, RPM packages can have more than one file in the payload.
To specify a format for each item in an array, use square brackets. For example:
rpm -q --queryformat "[%-50{FILENAMES} %{FILESIZES}\n]" sendmail
/etc/NetworkManager/dispatcher.d/10-sendmail       96
/etc/mail                                          4096
/etc/mail/Makefile                                 92
/etc/mail/access                                   469
/etc/mail/access.db                                0
/etc/mail/aliasesdb-stamp                          0
/etc/mail/domaintable                              233
/etc/mail/domaintable.db                           0
/etc/mail/helpfile                                 5584
/etc/mail/local-host-names                         64
This example lists the files and file sizes within a package, with the listing of files truncated for size.
If you want to mix array tags with non-array tags, you can use an equals sign, =, in front of the tag name to specify that the given tag should be repeated for each item in the array. For example:
rpm -q --queryformat "[%-15{=NAME} %-50{FILENAMES}\n]" sendmail bash
sendmail        /etc/NetworkManager/dispatcher.d/10-sendmail      
sendmail        /etc/mail                                         
sendmail        /etc/mail/Makefile                                
sendmail        /etc/mail/access                                  
sendmail        /etc/mail/access.db  
bash            /bin/bash                                         
bash            /bin/sh                                           
bash            /etc/skel/.bash_logout                            
bash            /etc/skel/.bash_profile                           
bash            /etc/skel/.bashrc           
This example, also truncated for size, lists the package name along with the file name for the files contained in these two packages.