home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13797 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.4 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!doc.ic.ac.uk!uknet!warwick!warwick!not-for-mail
  2. From: maupb@csv.warwick.ac.uk (Mr J L Saunders)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: How do I get a particualr line of a file?
  5. Message-ID: <1ep3j0INNnvk@clover.csv.warwick.ac.uk>
  6. Date: 22 Nov 92 23:02:56 GMT
  7. References: <pec2.722467852@Isis.MsState.Edu>
  8. Organization: Computing Services, University of Warwick, UK
  9. Lines: 26
  10. NNTP-Posting-Host: clover.csv.warwick.ac.uk
  11.  
  12. In article <pec2.722467852@Isis.MsState.Edu> pec2@ra.msstate.edu (Paul E. Carroll) writes:
  13. %This seems extremely simple, but I've run into the problem several times
  14. %and gotten stumped each time.  So how do I view a particualr line of a 
  15. %file?  Head looks at the top, tail the end, cat - echo - more - or less-
  16. %look at the whole thing... but what if I want to see just line 30?
  17. %or JUST line 210?  I'm stumped.
  18.  
  19. Have a look at the manual for awk...
  20.  
  21. Specifically, you'd want
  22.  
  23. awk '{if (NR == line) print}' line=linenumber filename
  24.  
  25. Where linenumber is the line you want, and filename is the file you're looking
  26. at. eg. 
  27.  
  28. >awk '{if (NR == line) print}' line=5000 /usr/dict/words
  29. concrete
  30.  
  31.  
  32. Cheers,
  33. Jason
  34. -- 
  35.                        Jason L Saunders [ RouE ]      
  36.                      email: maupb@csv.warwick.ac.uk
  37. snail: Warwick Business School, University of Warwick, Coventry CV4 7AL, UK
  38.