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?
Add a comment
|
1 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
-
Once it gets to the prompt stating
Is this ok[y/N]:
it exits withExiting on user Command
. Any ideas?– ScottJul 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. 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?– ScottJul 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 ofyum 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 simplyprint
ing a line that contains the first field. Everything in awk is based on running matches against each input line and performing actions. Jul 1, 2011 at 20:21