Path: utzoo!attcan!uunet!unsvax!jimi!tahoe!apple!mrspoc!itkin From: itkin@mrspoc.Transact.COM (Steven M. List) Newsgroups: comp.unix.questions Subject: Re: How read a line of a file from C-shell? Message-ID: <1990Oct25.005645.2969@mrspoc.Transact.COM> Date: 25 Oct 90 00:56:45 GMT References: <8913@ncar.ucar.edu> Reply-To: itkin@guinan.Transact.COM Organization: Transact Software, Inc., Los Altos, CA Lines: 29 tparker@bierstadt.scd.ucar.edu (Tom Parker) writes: >Thanks to all those that replied. > >The most feasible tip (so far) was to read the file using sed, e.g.: > > set lines = `wc -l $file` > > while ($i <= $lines[1]) > set line = `sed -n ${i}p $file` > echo $i $#line $line > # (Process $line here) > @ i++ > end > >This seems to work well, as long as the file doesn't contain any >meta-characters. (I could put the `sed ...` in double quotes, but then I >can't tokenize the line). One small optimization: set -n "${i}p;${i}q" $file This will cause sed to STOP when it has printed the line you want. -- +----------------------------------------------------------------------------+ : Steven List @ Transact Software, Inc. :^>~ : : Chairman, Unify User Group of Northern California : : {apple,coherent,limbo,mips,pyramid,ubvax}!itkin@guinan.Transact.COM :