# File Operation

**URL:** <https://www.ruby-forum.com/t/file-operation/177897>\
**Category:** Ruby\
**Created:** [October 26, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/file-operation/177897 "2009-10-26T12:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhas123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@subhas123](https://www.ruby-forum.com/u/subhas123)\
**Post date:** [October 26, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/file-operation/177897/1 "2009-10-26T12:51:42Z")

</div>

Can you tell me if I can move to a perticular Line number like ‘C’?

---

<div class="post-metadata">

**Author:** ![subhas123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@subhas123](https://www.ruby-forum.com/u/subhas123)\
**Post date:** [October 26, 2009, 1:20pm UTC](https://www.ruby-forum.com/t/file-operation/177897/2 "2009-10-26T13:20:22Z")

</div>

2009/10/26 Subhas M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Can you tell me if I can move to a perticular Line number like ‘C’?

What C library allows to “move to a particular line number”? I am not  
aware of something like that and it can work efficiently only if you  
have an index or lines with uniform length.

Please look at IO#tell and IO#seek. If you want line by line jumping  
there is no other way as to read the file from the beginning and stop  
at the appropriate line number.

The only option to speed that up is to build up an index of lines and  
then use IO#seek to position accordingly. If you also write to the  
file that approach will soon get very complicated.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![subhas123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@subhas123](https://www.ruby-forum.com/u/subhas123)\
**Post date:** [October 26, 2009, 2:52pm UTC](https://www.ruby-forum.com/t/file-operation/177897/3 "2009-10-26T14:52:19Z")

</div>

Thanks Robert
