Product SiteDocumentation Site

4.2.10.3. 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/aliases 1295
/etc/aliases.db 12288
/etc/mail 4096
/etc/mail/Makefile 748
/etc/mail/access 331
/etc/mail/access.db 12288
/etc/mail/domaintable 0
/etc/mail/domaintable.db 12288
/etc/mail/helpfile 5588
/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 jikes
sendmail /usr/lib/sendmail
sendmail /usr/sbin/mailstats
sendmail /usr/sbin/makemap
sendmail /usr/sbin/praliases
sendmail /usr/sbin/sendmail.sendmail
sendmail /usr/sbin/smrsh
sendmail /usr/share/man/man1/mailq.sendmail.1.gz
sendmail /usr/share/man/man1/newaliases.sendmail.1.gz
sendmail /usr/share/man/man5/aliases.sendmail.5.gz
sendmail /usr/share/man/man8/mailstats.8.gz
sendmail /usr/share/man/man8/makemap.8.gz
sendmail /usr/share/man/man8/praliases.8.gz
sendmail /usr/share/man/man8/rmail.8.gz
sendmail /usr/share/man/man8/sendmail.8.gz
sendmail /usr/share/man/man8/smrsh.8.gz
sendmail /var/spool/clientmqueue
sendmail /var/spool/mqueue
jikes /usr/bin/jikes
jikes /usr/doc/jikes-1.18/license.htm
jikes /usr/man/man1/jikes.1.gz
This example, also truncated for size, lists the package name along with the file name for the files contained in these two packages.