Ruby File IO question; Maintain file read position between script executions
- by macek
I have two files a.txt and b.txt (henceforth a and b).
My script iterates through a, does some operation, and potentially inserts a line to b.
In the event the script stops, I need it to pick up where it left off. In the example below:
foo was copied to b
bar was copied to b
zim was not copied to b (did not pass some criteria)
gaz was copied to b
Script stops (for whatever reason)
When script starts again, how to open a and start on line "dib"?
a.txt
foo
bar
zim
gaz // <= last successful copy
dib // <= I want to start here on next script execution
gir
b.txt
foo
bar
gaz // <= note omission of "zim" above gaz