On a bash console, if I do this:
cd mydir ls -l > mydir.txt
The > operator captures the standard input and redirects it to a file; so I
Apart from Veger's answer, there is one of more way to do it which also provides many other additional options.
Just open your rails project directory and enter the command:
rails c | tee output.txt
tee command also has many other options which you can check out by:
man tee