[comp.unix.questions] Redirecting stdin in CSH

jukoff@parc.xerox.com (11/06/90)

How do I redirect stdin in a Csh script?  For example, a simple "cat" command.

Here is the equivalent code in Bourne sh:

#!/bin/sh
exec 9<&0 < /etc/passwd			# Input any file here 
while read line
do
        echo $line...
done
exec 0<&9 9<&-

-----------------------------------------------------------------
It's very easy in Perl:

#!/usr/local/bin/perl

while (<>) { print ; }

-----------------------------------------------------------------
But I'm stumped in Csh.  For example, this doesn't work (the Csh converts
newlines to spaces on input -AND- foreach is space-delimited):
#!/bin/csh

foreach line (`cat /etc/passwd`)
        echo $line...
end

+---------------------------------------------------------+
| Steven Jukoff,             Phone: (415)494-4316         |
| Xerox PARC                 DDN:   jukoff@parc.xerox.com |
+---------------------------------------------------------+