Install yum packages based on regular expression

regular expressionsyum

I would like to install a batch of openoffice.org-* packages from the yum repository. The catch is that I want to exclude the dozens of openoffice.org-langpack* files when I do it. I also don't want to have to run two commands (i.e. yum install openoffice.org-*;yum remove openoffice.org-lang*). I've attempted to run the command yum install openoffice.org-[^l].* without any luck, as it looks for a package labeled exactly as typed. What command can I run to achieve this?

Best Answer

There are few problems that can't be solved with a healthy dose of awk-fu:

yum list | awk '$1 ~ /^openoffice\.org-[^l].*$/ { print $1 }' | xargs yum install