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?

link|improve this question

80% accept rate
feedback

1 Answer

up vote 1 down vote accepted

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
link|improve this answer
Once it gets to the prompt stating Is this ok[y/N]: it exits with Exiting on user Command. Any ideas? – Scott Jul 1 '11 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 '11 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 '11 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 '11 at 20:21
Most excellent. Thank you good sir! – Scott Jul 1 '11 at 20:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.