Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpsal2!morrell From: morrell@hpsal2.HP.COM (Michael Morrell) Newsgroups: comp.unix.questions Subject: Re: wanted: utility to extract lines by line-no. Message-ID: <2450007@hpsal2.HP.COM> Date: 7 Apr 88 21:04:15 GMT References: <1600@lll-lcc.aRpA> Organization: HP System Architecture Lab, Cupertino Lines: 31 > Does anyone know of a utility which will extract the nth line of a > file? I can easily write one but then I thought a general case > utility might exist. The utility could have the following > description: > > extract line-no [files] > > Extract a specified line number, range of lines, or > series of lines from stdin or a series of files. > > > Thanks in advance, > Jeremy Uejio (pronounced 'oo-ay-joe') > uejio@lll-lcc.llnl.gov ---------- Try using "sed". sed -n a,bp file will extract lines a thru b from "file". To get a series of lines, use sed -n '1,3p;10,21p;33,40p' file or sed -n -e 1,3p -e 10,21p -e 33,40p file Michael Morrell