Can you redirect csh's $<?

Can you redirect csh's $<?

Post by James Bust » Fri, 17 Feb 1995 10:06:24



I have tried using

        set var $< < infile

but that doesn't do anything, $< seems to always read from stdin. Is there
any way to do what I want, or perhaps I should consider this a bug in csh?
--
                                James Buster

 
 
 

Can you redirect csh's $<?

Post by Chris Washbu » Sat, 18 Feb 1995 02:20:23


: I have tried using

:       set var $< < infile

: but that doesn't do anything, $< seems to always read from stdin. Is there
: any way to do what I want, or perhaps I should consider this a bug in csh?
: --
:                               James Buster

set var=`cat infile`
--
Christopher A. Washburn                 UNIX Systems Administrator
Kulicke & Soffa Industries          Voice:  (215) 784-6832
2101 Blair Mill Road                    Fax:    (215) 659-7588


 
 
 

Can you redirect csh's $<?

Post by James Bust » Sun, 19 Feb 1995 05:01:50





>: I have tried using

>:   set var $< < infile

>: but that doesn't do anything, $< seems to always read from stdin. Is there
>: any way to do what I want, or perhaps I should consider this a bug in csh?
>: --
>:                           James Buster

>set var=`cat infile`

But that isn't the same thing. "set var=$<" reads one *line* of input,
whereas "set var=`cat infile`" reads the whole file. I now realize I
have misstated my question. In sh it is possible to read a file, one
line at a time, like this:

while true;do
    read var
done < infile

If $< could be redirected, then it might be possible in csh as well.
--
                                James Buster

 
 
 

Can you redirect csh's $<?

Post by Tom Park » Sun, 19 Feb 1995 06:43:19


[stuff deleted]

: But that isn't the same thing. "set var=$<" reads one *line* of input,
: whereas "set var=`cat infile`" reads the whole file. I now realize I
: have misstated my question. In sh it is possible to read a file, one
: line at a time, like this:

: while true;do
:     read var
: done < infile

: If $< could be redirected, then it might be possible in csh as well.
: --
:                               James Buster

The best way I have found to read from a file in csh, is via 'sed':

#!/bin/csh -f
# Sample csh script to read lines from a file.

    set noglob
# Determine number of lines in the file
    set lines = `wc -l < $file` || exit 2      # "<" so wc won't print filename.

# Loop through each line

    while ($i <= $lines)
       set string = "`sed -n '$i{p;q;}' $file`"
       # Illustrative printout
          set length = `expr "$string" : '.*'`
          set words = ($string)
          echo "Line=$i length=$length words=$#words"
          echo "$string"

    end

--
+--------------------------------------------------------------------+
| Tom Parker             |  National Center for Atmospheric Research |

+--------------------------------------------------------------------+

 
 
 

Can you redirect csh's $<?

Post by Hrvoje Niks » Sat, 25 Feb 1995 21:18:09



> I have tried using
>    set var $< < infile
> but that doesn't do anything, $< seems to always read from stdin. Is there
> any way to do what I want, or perhaps I should consider this a bug in csh?

Wrong.  csh reads from tty.  You must use
alias read 'set \!* = `head -1`'
and use read var.

Hrv
--
Hrvoje Niksic                |

http://www.srce.hr/~hniksic/ |  University of Zagreb, Croatia
-------------------------------------------------------------------

Quote:>Is there any virus protections software for UNIX systems??

Yes.  It is called UNIX.
 
 
 

1. <<<<<soundconfig problem <<<<<<<

hi,
I have a PC100 m747 mainboard
with onboard SIS AGP 6326 8meg videocard
with onboard Sound 3d with sounblaster 16 and WSS support

my SIS videocard works fine
i have problems to configure the soundcard
it claims to be soundblaster compatible , but installing a
'sounblaster 16' , 'soundblaster pro' 'WSS' 'MAD16' has no effect
just "modprobe: devive is busy or not found"

--
Microsoft, just the product of a society
     that's lost it's good manners

--
Microsoft, just the product of a society
     that's lost it's good manners

--
Microsoft, just the product of a society
     that's lost it's good manners

2. Linux Firewalls which one to use???

3. I need a example of X .twmrc file PLEASE <<<<<<<<<<<<<<<<<<<<<

4. Sound Pro support under Linux? (CMI 8330, HT1869V+)

5. SOLARIS 2.3 NOT getting the NAMESERVER <<<<<<<<<<<<<<<<<<<<

6. HP DeskJet 1120C

7. I think I've found the rectum of the internet.<<<<<<<<<<<<

8. alarm, signal and read

9. Script for makeing whole bunch of account of sol. 2.3 <<<<<<<<<<<<<<<<<

10. CDE <<<<<<<<<-------------- Need Help !

11. How can grep the 8th of Field <<<<<<<<

12. How can I trap a user in script <-<-<-<-<-<-<-<-

13. CPAN question <<<<<<<