home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!gatech!destroyer!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!atlantis!aaron
- From: aaron@atlantis.uucp
- Subject: Getting the nth line of a file
- Message-ID: <1993Jan25.163208.11697@atlantis.uucp>
- Reply-To: aaron%atlantis@kakwa.ucs.ualberta.ca
- Organization: Atlantis Communications, Edmonton, AB, Canada
- X-Newsreader: TIN [version 1.1 PL8]
- Date: Mon, 25 Jan 1993 16:32:08 GMT
- Lines: 21
-
- Is there an easy, elegant, and quick way to get the Nth line of a file in UNIX?
- Or, failing that, in C?
-
- Currently I use the simple, but somewhat slow:
-
- head -n | tail -1
-
- If n is very large(in the problem I'm working on, it's a random number from 1
- to ~20000), then this can take several seconds. Is there a basic UNIX command
- I've failed to find in searching the man pages? Is there something that works
- a bit more quickly using ex, or ed?
-
- Please email replies, because the feed here is a bit slow. If your email
- bounces(not all mailers like my reply-to), then feel free to post--it'll just
- take me a few days to see your message.
-
- --
- ---Alfvaen(Still looking for "October's Baby")
- "Clocks don't bring tomorrow--knives don't bring good news." ---Bruce Cockburn
- Current Album--Genesis:Abacab
- Current Read--Sean Russell:The Initiate Brother
-