How can I read one line at a time with C shell in unix

SIMEL picture SIMEL · Oct 25, 2010 · Viewed 26.7k times · Source

I try to make a small script, using c shell, that will take a file made of several lines, each containing a name and a number and sum all numbers that a have certain name. How can I put into a variable the next line each time?

the summig part I do by: (after I'll be able to get a full line to $line)

set line =($line)
@ sum = $sum + $line[2]

Answer

SIMEL picture SIMEL · Oct 27, 2010

I have managed to solve it using the next piece of code:

foreach line ("`grep $1 bank`")
    echo $line
    set line_break = ($line)
   @ sum = $sum +$line_break[2]
end
echo $1\'s balance id: $sum\$