#!/bin/sh

#read content of a file line by line and echo read line to monitor

# Open an existed file (test) for reading and
# assign a file descriptor 3 to this file.
# File descriptor is used later for identifying  this file
exec 3<test

LINE_NUM=1

# Redirect all stdin of any command to read from opened file (test) of descriptor 3
while read LINE 0<&3
do
    echo  "Line ${LINE_NUM} of file (test) is: ${LINE}"
    let LINE_NUM=${LINE_NUM}+1
done

# close opened file:
exec  3>&-
