I didn't find this one here so adding it, I had some issues getting the full output.
You can redirect STDERR to STDOUT if you want to capture STDERR using backtick.
output = `grep hosts /private/etc/* 2>&1`
source: http://blog.bigbinary.com/2012/10/18/backtick-system-exec-in-ruby.html