Problem with Ruby script output to file

I have a Ruby script that outputs a bunch of text. As an example:

puts "line 1"
puts "line 2"
puts "line 3"
# etc... (obviously, this isn't how my script works..)

There is not much data here - perhaps about 8 kilobytes of character data.

When I run the script on the command line, it works as expected:

$ ./my-script.rb

line 1
line 2
line 3

But when I insert it into the file, the output is truncated exactly at 4096 bytes:

$ ./my-script.rb > output.txt

What could cause a 4kb stop?

Update: I just rewrote the script to output directly to a file, instead of typing on the screen and fixing the output, and the problem is still happening!

$output = File.new("file.txt")
$output << "line 1"  #etc..
+3
source share
1 answer

? 4kB -, , ( 8kB, ), , .

+4

Source: https://habr.com/ru/post/1745931/


All Articles