Shell Programming/I/O Redirection

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

exec 6<$tasklist
while read -u 6 raw
       # Do for each line
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.