How can I test if a list of files exist?

后端 未结 6 2118
花落未央
花落未央 2021-02-15 18:25

I have a file that lists filenames, each on it\'s own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be

6条回答
  •  梦如初夏
    2021-02-15 19:13

    I wanted to add one small comment to most of the above solutions. They are not actually testing if a particular file exists or not. They are checking to see if the file exists and you have access to it. It's entirely possible for a file to exist in a directory you do not have permission to in which case you won't be able to view the file even though it exists.

提交回复
热议问题