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

  1. Path: sparky!uunet!mcsun!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: <1epg3hINN5ae@violet.csv.warwick.ac.uk>
  6. Date: 23 Nov 92 02:36:33 GMT
  7. References: <pec2.722467852@Isis.MsState.Edu> <1992Nov22.235943.13501@umbc3.umbc.edu>
  8. Organization: Computing Services, University of Warwick, UK
  9. Lines: 28
  10. NNTP-Posting-Host: violet.csv.warwick.ac.uk
  11.  
  12. In article <1992Nov22.235943.13501@umbc3.umbc.edu> rouben@math9.math.umbc.edu (Rouben Rostamian) writes:
  13.  
  14. %To print line 30:
  15. %sed -n 30p filename
  16. %
  17. %To print lines 30 to 35:
  18. %sed -n 30,35p filename
  19. %
  20. %--
  21. %Rouben Rostamian
  22.  
  23. Yep! I should have thought of sed before resorting to awk!
  24.  
  25. For tcsh and csh users, to make life even simpler do:
  26. alias fline "sed -n \!:1p \!:2"
  27.  
  28. and then to get line 7 of file foo, type:
  29. fline 7 foo
  30.  
  31. and to get lines 30 to 35 type:
  32. file 7,35 foo
  33.  
  34. Cheers,
  35. Jason
  36. -- 
  37.                        Jason L Saunders [ RouE ]      
  38.                      email: maupb@csv.warwick.ac.uk
  39. snail: Warwick Business School, University of Warwick, Coventry CV4 7AL, UK
  40.