On 22Sep2018 14:09, Roger Heflin <rogerhef...@gmail.com> wrote:
If you have the original disk and can mount the filesystem then do this:

create a script like this and call it say /dir/testcatfile:
cat $1 > /dev/null
RC=$?
if [ ${RC} != 0 ] ; then
 echo "$1 is corrupt"
fi

Just a shell remark: because the shell considers any command to be a predicate, you can just go:

   cat "$1" >/dev/null || echo "$1 is corrupt"

i.e. assert the truth of the "cat" invocation (truth means success). Since "||" is short circuiting OR, just like C, the OR expression tries the first predicate (cat), and only tries the second if the first is false.

Truth or consequences.

chmod +x /dir/testcatfile

Then do this:
find /tmp -type f  -exec /dir/testcatfile {} \;

each file it gets an io error on will print out a message.

You can make this considerably faster via xargs:

 find /path/to/your/drive -type f -print0 \
 | xargs -0 cat -- >/dev/null 2>cat-errors.txt

which will try to cat everything in batches and report errors to "cat-errors.txt" for later review.

It should be substantially faster than the "find ... -exec script" version.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org

Reply via email to