home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15996 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.6 KB  |  35 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!ftpbox!news.acns.nwu.edu!zaphod.mps.ohio-state.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!sdd.hp.com!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!caen!nic.umass.edu!news.amherst.edu!twpierce
  3. From: twpierce@unix.amherst.edu (Tim Pierce)
  4. Subject: Re: Getting the nth line of a file
  5. Message-ID: <C1HyrJ.FLL@unix.amherst.edu>
  6. Organization: Elitist Usenet Administrators, Stuff and Nonsense Division
  7. References: <1993Jan25.163208.11697@atlantis.uucp> <1993Jan26.151133.18029@atlantis.uucp> <1993Jan26.232708.10878@odin.corp.sgi.com>
  8. Date: Wed, 27 Jan 1993 05:18:54 GMT
  9. Lines: 24
  10.  
  11. In article <1993Jan26.232708.10878@odin.corp.sgi.com> vidya@akshay.csd.sgi.com (Vidya Alankar) writes:
  12.  
  13. >In article <1993Jan26.151133.18029@atlantis.uucp>, aaron@atlantis.uucp writes:
  14. >
  15. >|> > I'm not sure if
  16. >|> > sed quits after printing the Nth line, which is really what you want
  17. >|> > for speed; the sed man page always confuses me.
  18.  
  19. The sed man page isn't really that bad.  Just keep remembering Indiana
  20. Jones: "Only the penitent will pass."
  21.  
  22. >It does read the full file. I do not know enough about sed to say if they
  23. >is a way to stop after the Nth line. The awk command above does just this.
  24.  
  25. sed -n 'Npq' (where N is the number of the line to print).
  26.  
  27. This is infinitely more desirable than any of the other sed solutions
  28. listed.  Since the command contains no metacharacters or spaces, I
  29. doubt you need quotes.
  30.  
  31. -- 
  32. ____ Tim Pierce                / 
  33. \  / twpierce@unix.amherst.edu /               Rocks say goodbye.
  34.  \/ (BITnet: TWPIERCE@AMHERST) / 
  35.