How to iterate through list of filenames in linux

Posted by Prem on April 19th, 2010 filed in Linux, Tech topics

Today, somebody asked me how to iterate through a list of filenames given in a text file, and do something with it.  So, I did, and then thought i would put it here, so it might help somebody else.

So, the script goes like this:

for f in `cat x` ; do
  if ! test -e $f
  then
    echo $f
  fi
done

Leave a Comment

You must be logged in to post a comment.