Question

I am trying to parse some access logs with Ruby, the file itself is 363MB. I'm working in IRB and when I try to assign the text from the document to a variable data = logs.read it begins returning all the text into the interpreter, which at 363MB is an issue.

How do I assign the contents of a file to a variable without returning the value back in the interpreter?

Was it helpful?

Solution

Start your irb as below :

irb --simple-prompt --noecho

  • --simple-prompt is to get the IRB prompt as >>
  • --noecho is to off the echo on IRB

Here is an example:

C:\>irb --simple-prompt
>> x = 2
=> 2
>> exit

C:\>irb --simple-prompt --noecho
>> x = 2
>>

OTHER TIPS

You can use ; and then enter any operator, for example:

data = logs.read; nil

It will output just nil.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top