Sunday, September 7, 2008

Sending output from one command to another

When I recently updated xorg-server to version 1.5.0 (which comes with the new X.org that is released soon!) I needed to rebuild some of the drivers (packages) that comes with it. To get the list of drivers I use the command qlist.
$ qlist -I -C x11-drivers/
which outputs a list of packages from the category x11-drivers that are installed (-I) and without color (-C). Although it's nice to get a list like the one I got:
$ qlist -I -C x11-drivers/
x11-drivers/nvidia-drivers
x11-drivers/xf86-input-evdev
x11-drivers/xf86-input-keyboard
x11-drivers/xf86-input-mouse
x11-drivers/xf86-video-nv
it's a bit annoying if you have to copy and past all these onto the command line as parameters to the 'emerge' command. So what we do is get the qlist to list these packages into the emerge command. This is done using the "$" symbol, which first evaluates the output of its embedded command, and then outputs it as a parameter to the parent command. To clarify:
$ parent-command $(command we want the output from)

which in our case turns out to be:
# emerge $(qlist -I -C x11-drivers/)
This starts the emerge and re-compile of all our drivers. Now we wait... ;)

No comments: