Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
~]$packageManager list packages 

gives back

wordA1 wordB1 wordC1
wordA2 wordB2 wordC2
wordA3 wordB3 wordC3

I then want to run a second command on all B-column words, e.g.

~]$packageManager install packages wordB1 wordB2 wordB3

How can I achieve this elegantly, maybe as one liner with xargs..?

share|improve this question
up vote 3 down vote accepted
$ sudo yum install $(yum list packages | awk '{ print $2 }')
share|improve this answer
It works with $1. Thanks! – Stephan Kristyn Sep 5 '12 at 13:18
Just an example since you want to get the second column. – quanta Sep 5 '12 at 13:21

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.