+2  A: 

one way

while read -r folders
do
  # add -maxdepth 1 if recursive traversal is not required
  find "$folders" -type f -iname "*.txt" | while read -r FILE
  do
      echo "do something with $FILE"
  done
done <"file"

or

folders=$(<file)
find $folders -type f -iname "*.txt" | while read -r FILE
do
    echo "do something with $FILE"
done

Bash 4.0 (if recursive find is required)

shopt -s globstar
folders=$(<file)
for d in $folders
do
  for file in $d/**/*.txt
  do
    echo "do something with $file"
  done
done
ghostdog74
I would add the -prune option to find so that subdirs aren't searched
ennuikiller
OP doesn't indicate, but he can always add `-maxdepth 1` if he doesn't want to traverse directory
ghostdog74
+1  A: 

Given the post is simply asking for a list of files, it's quite simple:

tmp=$IFS
IFS=$(echo -en "\n\b") 
for i in `cat folders.txt` ; do
    ls -l "$i/*.txt"
done
IFS=$tmp
eqbridges
take care of folder names with spaces. put quotes where necessary
ghostdog74
even though the original post is not asking for it, I've added it. note, your examples are not all taking spaces into consideration.
eqbridges
really? which ones. tell me and i will edit it.
ghostdog74
by default read uses IFS.
eqbridges
so which one is not correct wrt files with spaces? you have not told me, so i can correct it.
ghostdog74
i did tell you --> your usage of 'read' is problematic. you use it in 3 places. "man read" is your friend.
eqbridges
I know, it doesn't take care of things like newlines in files. But for spaces, its more than fine. Why don't you try them out and see. If it doesn't work for you, let me know which version and I will try and correct them.
ghostdog74
it's your example, spend some time with it and you'll see what i mean.
eqbridges
+2  A: 

Simply do it on command line:

xargs ls -l < folders.txt | grep '.txt$'
Vijay Sarathi
I like the simplicity of this answer.
Ethan Post
lose the cat and its even simpler. `xargs ls -l < folder.txt`. or `xargs -a folder.txt ls -l`
ghostdog74
@Ethan, i like the simplicity too, but only for displaying those txt files. If further processing for each file is required, this has to be enhanced.
ghostdog74