It's bash shell syntax for redirections (see the 'REDIRECTION' section in man bash) that effectively combines STDOUT and STDERR so that they both appear in STDOUT, and thus both go through the pipe, and thus both are available via <RS>. If the 2>&1 was omitted, then <RS> would have only what $cmd outputted to STDOUT, and not anything to STDERR. Update: DOH! too slow.. maybe i should have responded before approving :)
Comment on Re: Can someone explain how this works?