This is really a trivial question, but I was stumped how to use e.g. “find” to list all files in a directory with read errors.
I dont want to copy a file to find out. That is counterproductive. There must be a faster way.
How do you find a list of files in a directory recursively that has read or io errors ?
Keep in mind that this command (find . -type f -not -readable) really finds files that you cannot read (i.e., you lack read permission), not just files with read errors (i.e., disk errors). For example, if the directory contains files owned by another user (such as root) and you don’t have read access, find will print those file paths too.
doesnt work, and throws an error, but was good enough to adapt to work for me
The correction I posted, perfectly found the files with read errors, so it works great for me. It was such a minor change to his solution that I did not bother to mention it.
As I mentioned, the command finds files with read errors, but it also finds healthy files where you don’t have read permission (e.g., a file owned by root with mode 0600, -rw-------).
Thanks mate for sharing these insights mate as I found it very much useful and informative to be honest also as a new member I am loving this community so far and looking forward for more such discussions.