I was reading this and was going to mention that that operation is easy with imagemagick, which can read raw files directly. The tag solution is much quicker though. dcraw can also save the color planes separately as greyscale images, and could probably convert with a swapped interpretation as well.
The -d option of dcraw can export the pixels as-is, it will appear as greyscale with no debayering. It would need further processing.
Separating color channels with imagemagick is described herehttp://www.imagemagick.org/Usage/color_basics/#separate
It's possible to swap channels with "piplining" and not use temporary files.