How read a line of a file from C-shell?

Tom Parker tparker at bierstadt.scd.ucar.edu
Sat Oct 20 09:26:11 AEST 1990


I'm having trouble finding a way to read a line of a file in the C-shell.

For instance, I would like my script to read the first line of a file,
process it, then read the second line, process it, etc.

I tried something like      foreach line(`cat file`)
but this seems to process the entire file, a word at a time.

The only method I've gotten to work is this inelegant structure: 

      set line = `head -$n | tail -1`   # Read n-th line

Does anyone have better ways to do file I/O in a C-shell script?

Thanks, Tom



More information about the Comp.unix.questions mailing list