When I execute less package.rpm, less shows me all sorts of meta info about the package. What is less exactly doing - does it have built in code to be able to extract meta info, or is an rpm structured in a way that the first part just looks like a text file?I would assume the former, since head is not so helpful here. But to get to the real question: If I would like to grep through this meta data less showing me, how can I accomplish this?
What is less doing with rpm, and how do I get that text without rpm
grep;rpm;less
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.