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