Frage

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?

War es hilfreich?

Lösung

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
>>

Andere Tipps

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

data = logs.read; nil

It will output just nil.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top