read a file line by line

read a file line by line

Post by Sean McHal » Tue, 11 Jul 2000 04:00:00



i'm trying to open a file in C shell so that it can be parsed, i've
tried doing this:
$> my.csh filename
foreach line (`cat $1`)
  .....
end
but i get an error, this is the only way i could think of going through
the file line by line. any suggestions?
s
 
 
 

read a file line by line

Post by Peter Sundstro » Tue, 11 Jul 2000 04:00:00



>i'm trying to open a file in C shell so that it can be parsed, i've
>tried doing this:
>$> my.csh filename
>foreach line (`cat $1`)
>  .....
>end
>but i get an error, this is the only way i could think of going through
>the file line by line. any suggestions?

Do you self a favour and read
http://www.perl.com/pub/language/versus/csh.html

then use sh/ksh/bash/zsh like

while read line
do
  ..
done <filename

 
 
 

read a file line by line

Post by Walter T Rejune » Tue, 11 Jul 2000 04:00:00



> i'm trying to open a file in C shell so that it can be parsed, i've
> tried doing this:
> $> my.csh filename
> foreach line (`cat $1`)
>   .....
> end
> but i get an error, this is the only way i could think of going through
> the file line by line. any suggestions?
> s

There is actually a very simple answer to this. Stop using csh and start
using ksh. Once you do that you will find that not only can you do a lot
of things with ksh that csh can't handle, but you'll also be working
with a shell that was developed by a real professional rather then a
bunch of college computer-science-weinies.
 
 
 

read a file line by line

Post by bmar.. » Tue, 11 Jul 2000 04:00:00



   >i'm trying to open a file in C shell so that it can be parsed, i've
   >tried doing this:
   >$> my.csh filename
   >foreach line (`cat $1`)
   >.....
   >end
   >but i get an error, this is the only way i could think of going
   >through the file line by line. any suggestions?
   >s
What exactly do you want to do with the file?  You might be better off using
sed or awk..
Net-Tamer V 1.08X - Test Drive