> > read all my variables < my.input.file > > > > If you need to read several lines, use exec: > > > > exec 3<&0 # save old stdin to unused file descriptor 3 > > exec < my.input.file # make my.input.file stdin > > read line1 > > read line2 > > read line3 > > exec <&3 # get back original stdin > > exec 3<&- # and close fd 3. > >Thanx, that will work. > > > > There is redirection to duplicate input or output to some file > > > descriptor (10<inpfn , 11>outpfn), but I do have no clue whatsoever what > > > these file descriptors are used for and how. > > > > 0 is stdin, 1 is stdout, and 2 is stderr. The rest are yours to > > play with as you need. > >That's what I thought, but what can you do with them? None of the bash >commands uses a file descriptor as argument. In the example you give, >you use them as a temp var to store the standard I/O files. Is there >anything else?
You can do something like:
exec 10< datafile
and then later
read var1 var2 var3 ... <&10
will read the next line from descriptor 10, which is connected to the datafile.
You could also use ksh instead of bash; its "read" command has a -u option to specify a one-digit descriptor number.
Barry Margolin
documented on: 2000.12.20 Wed 12:56:54