Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

[Context] I'm developing a little app, as a hobby to learn ncurses, that catalogs and lists and searches within a set of documents (for now, they are the HOWTOs from TLDP).

The most tricky part of the app is, I believe, the file reader (show the contents of a file nicely). To really be able to provide a good enough user experience, given that the HOWTOs are somewhat long, it would be a valuable feature if I can "save" the line where the user stopped reading, and start on that same line the next time the user opens up that same HOWTO [/context]

So to the real question: is there a command-line reader that can not only get a line X as a parameter and position the cursor at that line, but also tell me the line that was last shown? I understand that an app can't "return" that value, given that returns are either 0 or an ERROR#, so maybe some kind of system variable or shared memory or... ?

Given that I'll be doing the call from a C app, maybe a different solution that's not an external app will also serve me just right, I'm open to suggestions.

share|improve this question
view (part of vim) saves the file position in the viminfo file. At least, it does depending on your viminfo setting. – derobert Jan 8 '13 at 19:30
Oh that's a nice tip, I never knew about view... I think I would be more comfortable using a more newbie-friendly solution where a simple "q" or Ctrl+c would be enough to close the reader. But then, view is certainly something I will look into if unable to find a different solution. Also, I just tested it and view not only writes the markers to .viminfo but also opens the file in the mark already, so that would be one less concern... I think I'll end up using that if nothing similar appears. Thank you! – beder Jan 8 '13 at 19:38
Similarly to the vim situation open buffers in emacs retain their state unless you close the whole program (or explicitly kill the buffer). – dmckee Jan 8 '13 at 23:57
Just by the way. view is not only part of vim, it is vim. In Ubuntu, at least, both are symbolic links which resolve to /usr/bin/vim.gnome – Peter.O Jan 9 '13 at 5:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.