3

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?

1 Answer 1

3

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
4
  • Once it gets to the prompt stating Is this ok[y/N]: it exits with Exiting on user Command. Any ideas?
    – Scott
    Jul 1, 2011 at 20:12
  • Ah, yes, good point. This happens because you're using it on a pipe or from xargs. One of those. Do a 'yum install -y' instead. Note: it will not prompt you to continue.
    – Kyle Smith
    Jul 1, 2011 at 20:15
  • Perfect! If you don't mind me asking, I am a little familiar with awk, yet not enough to accomplish this, what is the $1 ~ accomplish?
    – Scott
    Jul 1, 2011 at 20:17
  • Awk breaks up fields into variables using whitespace by default (far more intelligently than cut for example). If you look at the output of yum list, the left "field" is the list of packages (installed or available). So we're doing a regular expression match of field 1 (using the ~ operator) and then performing an action when a line matches. In this case, we're simply printing a line that contains the first field. Everything in awk is based on running matches against each input line and performing actions.
    – Kyle Smith
    Jul 1, 2011 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .