Shell Programming/I/O Redirection

File descriptor (fd) 0 is stdin. Fd 1 is stdout. Fd 2 is stderr.

#!/bin/bash
tasklist=$1
exec 6<$tasklist
while read -u 6 raw
do
       # Do for each line
done
exec 6<&-

In the above example, exec globally opens $tasklist file for reading by assigning fd 6. The read command then reads fd 6 source line by line until end of file. The exec globally closes fd 6 in the last line.