What is less doing with rpm, and how do I get that text without rpm

If you browse through the less man page, you'll notice less has an INPUT PREPROCESSOR feature.

echo $LESSOPEN to view the location of this preprocessor, and use less/vim/cat to view its contents.

On my machine this preprocessor is /usr/bin/lesspipe.sh and it includes the following for rpms:

*.rpm) rpm -qpivl --changelog -- "$1"; handle_exit_status $?

In effect, less hands off openning the file to rpm, and shows you the pagination of its output.

Obviously, to grep through this info, simply grep the output of rpm directly:

grep "foo" < <(rpm -qpivl --changelog -- bar.rpm)

Or in general (thanks OrangeDog)

grep "foo" < <(lesspipe.sh bar.rpm)

Note: $LESSOPEN Does not simply hold the location of lesspipe.sh - it begins with a | and ends with a %s so invoking it directly would result in errors.


If I would like to grep through this meta data less showing me, how can I accomplish this?

very simply; if you want to grep on "Version" for example:

less your.rpm | grep "Version"

Note that less is using the rpm command; so better skip using less; and use rpm commands; like:

rpm -qip /path/to/uninstalled/rpm
rpm -qi installed.rpm

Tags:

Grep

Rpm

Less