'c' shell scripts

guidi at pegasus.UUCP guidi at pegasus.UUCP
Thu Dec 15 01:14:53 AEST 1983


How to read lines from a file and then go back to standard input
inside a shell script?  I use the following MODEL (Bourne Shell) which
may give some inkling on how to do it with other shells:
    tty=`tty`        # where std in is
    exec < a-file    # the file I want to read
    read line        # read a line from the file
    while [ "$?" = 0 ] # until error return (EOF) from "read"
    do
    echo $line       # process what I read from file
    read line        # get the next line (if any)
    done
    exec < $tty      # change std in to something else
    echo "terminal input?\c"   # etc.....
    read line
    echo $line



More information about the Comp.unix mailing list