How to check if all the paths on every line of a file is a valid path in Bash?

Viewed 195

I have a file with different paths on every line

path_1
path_2
...

and so on.

I need to check if all these paths are valid ones.

The way I am doing now is to create a new directory (tmp) and then writing

while read line; do cp $line > tmp; done < my_paths_file

and then checking if the number of files copied into tmp directory is equal to the number of lines in the file. This takes too long due to a lot of number of lines in my file.

Is there a smarter and quicker way to check the validity of all the paths?

2 Answers
Related