Read text file line by line

Hi everyone,

I am writing a BASH shell script that I will use to process data files. I have a text file that contains the names of the files to be processed, for example:

cat filenames.txt 
file1
file2
file3
file4
file5

What I would like to do is set up a FOR loop within my script that will iterate for the # of file names in the text file. Each time through the loop I will assign the successive file name to a variable. In other words, the first time through the loop the variable FILENAME will take on the value 'file1', the second time 'file2', etc. However I am not sure how to do that. Any help is greatly appreciated!

Mike

Simpler to do it with a while loop

while read LINE
do
    FILENAME="$LINE"
    # do something here with $FILENAME
done < filenames.txt

Hi Aia,

Thank you very much. That works great and is exactly what I need.

Mike