Read a specific line from a file: Difference between revisions

→‎From the bottom: Wrong: skip must be bounded.
(→‎{{header|TXR}}: Can do from the bottom, too, in bleeding edge code.)
(→‎From the bottom: Wrong: skip must be bounded.)
Line 314:
<lang txr>@(skip)
@line
@(skip nil1 2)
@(eof)</lang>
How this works is that the first <code>skip</code> will skip enough lines until the rest of the query successfully matches the input. The rest of the query matches a line, then skips two lines, and matches on EOF. So <code>@line</code> can only match at one location: three lines up from the end of the file. If the file doesn't have at least three lines, the query fails.
Anonymous user