Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any programs that can help identify files and directories belonging to unfinished bittorrent-downloads? I've made a mess, and I'm unsure of which downloads are finished and which are not. I could obviously use the bt-client, if I still had the torrent-files, but I don't. I'm therefor looking for way to identify likely unfinished bt-downloads - doesn't have to be 100% accurate.

I've noticed that bt-clients typically create empty-files, as well as leave files with "holes" (blocks of the file with just NULL-characters), so this could perhaps be a good way to find likely candidates. Sadly, I don't know any good Linux-commands for finding files with blocks of NULLs...

share|improve this question
It'd be a good idea to add name/version of your client. – pyroscope Apr 25 '13 at 18:01
up vote 3 down vote accepted

If your grep supports it; you could do a check by grep.

grep -P '\x00{NNN}' File

Where NNN is how many continuously zero bytes you want to match. Would typically be max USHRT_MAX or 65535.

-P is needed to use \x00

To list offsets use:

grep -Pboa '\x00{NNN}' File

So something in the direction of:

for f in *; do
    [ -e "$f" ] || break
    if grep -Pq '\x00{1000}' "$f"; then 
        mv "$f" ../likely_corrupt

Else you could use hexdump, xxd or the like and match for 000....

hexdump -ve '/1 "%02X"'

But that would be crazy slow.

Finally a very short C program could do the same.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.