position the file pointer 5 bytes from the end of the file and change the character to an X
IO::SEEK_CUR Seeks a certain number of bytes ahead of the current position.
IO::SEEK_END Seeks to a position based on the end of the file.
IO::SEEK_SET Seeks to an absolute position in the file. Identical to pos=.
f = File.new("test.txt", "r+")
f.seek(-5, IO::SEEK_END)
f.putc "X"
f.close
Related examples in the same category