Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 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
share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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