LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   File Test to make sure files aren't corrupt/damaged (https://www.linuxquestions.org/questions/programming-9/file-test-to-make-sure-files-arent-corrupt-damaged-251103/)

bluedevlx 11-04-2004 11:35 AM

File Test to make sure files aren't corrupt/damaged
 
Are there any unix commands to check the integrity of files?

Scenario:
There is a directory with nearly 50 files and you must copy them from the source to a destination but when you goto copy them it begins copying up to the first 100MB and then hangs resulting in a CTRL + C to cancel. And then you go directly to the last file that it stopped copying and you try to pull it over manually but it will not go because it's damaged/corrupt. Now you know that there are atleast 10 files out of these 100MB that are corrupt and you don't really want to sit there and have to copy all over again and when you do get to the next damaged file you bypass it and start copying everything over again. Now I didn't mention that when you copy you're only able to copy everything in one shot and those files that are damaged you add to en exclude file. So basically you'll sit there for hours waiting and waiting and then wam* you get hit with a screen that is stuck on one file so now you have to cancel the copy and add that filename to the exclude list.

Solution to this would be to create or find a file integrity checker that can check each file in a directory to make sure they aren't damaged/corrupt.

Now does anyone happen to know of the command to test a file for erroneous bytes that will cause it not to be accessable or used? I'm trying to figure out which command can do this.

itsme86 11-04-2004 11:44 AM

There's no such thing as "erroneous bytes that will cause it not to be accessable". A file copy program doesn't care about the contents of a file. It just reads one stream of bytes and writes to another.

You can, however, easily check to see if two files match with the md5sum command.

Quote:

itsme@itsme:~/C$ md5sum help.c
b1bf3ee1168d587996f21fa27127f21a help.c
itsme@itsme:~/C$
Then, after I copy the file I can run md5sum on the new file and make sure the sums match.

I'm not sure why your copy operation is freezing up, but it shouldn't have anything to do with the contents of the file itself. Maybe a device became unavailable?

bluedevlx 11-04-2004 11:50 AM

RE
 
That was just the scenario. Here is what i'm really doing sorry I should have said this a long time ago:

I'm trying to recover everything my JAZ 2GB by tarring it to my hda. Ok it's creating fine and then all of a sudden it gets to a file and it stops copying and begins to keep trying to copy the file over and over and i check the size on the tar and it stops growing. I then next just tried copying over the file directly to my hd and it copied almost 50% and began locking up and trying to copy over again and again. So I have to cancel and exclude the file because it's not going anywhere.


All times are GMT -5. The time now is 06:29 AM.