Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 671067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:19:58+00:00 2026-05-14T00:19:58+00:00

On a bash console, if I do this: cd mydir ls -l > mydir.txt

  • 0

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 get the listing of files in mydir.txt instead of in the standard output.

Is there any way to do something similar on the rails console?

I’ve got a ruby statement that generates lots of prints (~8k lines) and I’d like to be able to see it completely, but the console only “remembers” the last 1024 lines or so. So I thought about redirecting to a file – If anyone knows a better option, I’m all ears.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:19:59+00:00Added an answer on May 14, 2026 at 12:19 am

    You can use override $stdout to redirect the console output:

    $stdout = File.new('console.out', 'w')
    

    You may also need to call this once:

    $stdout.sync = true
    

    To restore:

    $stdout = STDOUT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I do 'Get Bash Here' on a network location the console isn't in
Possible Duplicate: Function to Clear the Console in R In bash, its like this:
In bash one can escape arguments that contain whitespace. foo a string This also
I have a sh/bash script that needs to call a batch file with parameters
I've a bash function that looks like this. function gg() { git add .
Let's say I've got a shell script called print_error.sh looking like this: #!/usr/bin/bash echo
This is the command I've been using for finding matches (queryString) in php files,
In an awk file, e.g example.awk, should the header be #!/bin/bash or #!/bin/awk -f
I am trying to get a cronjob to pipe output into a dated file
Please help me get an embedded ipython console to run inside a doctest. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.