Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!ncar!bierstadt.scd.ucar.edu!tparker From: tparker@bierstadt.scd.ucar.edu (Tom Parker) Newsgroups: comp.unix.questions Subject: Re: How read a line of a file from C-shell? Message-ID: <8913@ncar.ucar.edu> Date: 23 Oct 90 00:48:21 GMT Sender: news@ncar.ucar.edu Reply-To: tparker@bierstadt.scd.ucar.edu (Tom Parker) Organization: Scientific Computing Division/NCAR, Boulder, CO Lines: 39 Thanks to all those that replied. Several suggested using the C-shell $< function to read the lines from stdin. This would work, except that I am submitting my C-shell script as a job to a remote UNICOS system via NQS, and can't specify a stdin to my script (the script is the job itself). (By the way, I think that using `line` might be better than $<, since then you can check for an EOF with $status). One person suggested using 'cat' and setting IFS, but IFS is only in Bourne shell. 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). Thanks to all that replied, Tom +---------------------------------------------------------------------------+ | Tom Parker | | | | Consulting Office Internet: TPARKER@NCAR.UCAR.EDU | | Scientific Computing Division BITNET: TPARKER@NCARIO | | Nat'l Center for Atmospheric Research Phone: (303) 497-1227 | | Boulder, Colorado 80307 | +---------------------------------------------------------------------------+