Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site heurikon.UUCP Path: utzoo!linus!philabs!seismo!uwvax!heurikon!jeff From: jeff@heurikon.UUCP Newsgroups: net.unix Subject: Re: 'c' shell scripts - (nf) Message-ID: <148@heurikon.UUCP> Date: Sun, 1-Jan-84 15:32:57 EST Article-I.D.: heurikon.148 Posted: Sun Jan 1 15:32:57 1984 Date-Received: Mon, 2-Jan-84 07:29:45 EST References: <2101@fortune.UUCP>, <206@dual.UUCP> Organization: Heurikon Corp., Madison WI Lines: 28 > From: fair@dual.UUCP (Erik E. Fair) > I once used `a-truly-ugly-and-evil' way to read successive lines > of a file for csh. Combinations of head and tail can do the trick: > > # To keep the evil sh away... > set x=1 > while ($x < ????) > head -$x FILE | tail -1 (or minus however many lines you want) > end Sorry Erik, I think you'll have problems with big files. At least we would because our 'tail' has a bug: if the line number is > 99, strange things happen. To test, try: "tail -nnn bigfile | wc -l" And, you've got the same Un*x port that we do...Un*Plus+. (Let's both report it!) Ah!, but along the lines of your suggestion there *is* a solution! I've had good luck using 'sed' instead of the 'head'/'tail' combination. It's fast and flexible. Try a varient of this: x=3 oneline=`sed -n $x,"$x"p` echo $oneline -- Jeffrey Mattox, Heurikon Corp, Madison, WI {harpo, hao, philabs}!seismo!uwvax!heurikon!jeff (That path is correct, desipte what the headers might show.)