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?
Asked
Active
Viewed 3,753 times
3

Scott
- 407
- 1
- 5
- 14
1 Answers
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

Kyle Smith
- 9,683
- 1
- 31
- 32
-
Once it gets to the prompt stating `Is this ok[y/N]:` it exits with `Exiting on user Command`. Any ideas? – Scott Jul 01 '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 01 '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 01 '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 `print`ing 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 01 '11 at 20:21