It would appear that rpm
has no builtin option to suppress directories in the file list output.
However, you can use the --queryformat
option (without -l
) to print file modes and file names for each file, and then pipe the output to e.g. grep
to exclude those entries whose mode field starts with d
:
rpm -q --qf '[%{FILEMODES:perms} %{FILENAMES}\n]' some_rpm | grep -v '^d'
This would still print the mode fields of those entries that are actual files. In order to suppress that, you can use a slightly more complex sed
program instead:
rpm -q --qf '[%{FILEMODES:perms} %{FILENAMES}\n]' some_rpm | sed -nE '/^[^d]/s/.* //p'
This will suppress output by default, consider only those lines that do not start with d
, and remove the first column.
Previous version of the answer
However, you can use the fact that the verbose output will print an ls -l
style list of the files, and pipe the output to e.g. grep
to exclude those entries whose permissions field starts with d
:
rpm -ql -v some_rpm | grep -v '^d'
Note that this will still retain the "full" output style. If you want to restrict the output to the actual filename, you could pipe the output to a slightly more complex awk
program that will only print the last column, which is the actual filename. I have included a check to see if the file is a symlink, identified by ->
as next-to-last column, in which case it will print the link name instead of the link target:
rpm -ql -v some_rpm | awk '$1 !~ /^d/ {if ($(NF-1) != "->") {print $NF;} else {print $(NF-2)}}'
This will, however, stumble upon filenames with whitespace in it, so you need to be careful here.