The perlfunc man page has the following words: -T and -B :
The -T and -B switches work as follows. The first block or so of the file is examined for odd characters such as strange control codes or characters with the high bit set. If too many strange characters (>30%) are found, it a -B file; otherwise it a -T file. Also, any file containing a zero byte in the first block is considered a binary file.
Of course, now you can do a statistical analysis of several sqlite files, analyze their "first block or so" for "odd characters", calculate the probability of their occurrence, and this will give you an idea of ββhow likely this means that -B does not work for sqlite files.
However, you can also easily go the route. Could it fail? Yes, it is a heuristic. And bad at that. Therefore, do not use it.
Unix file type recognition is usually done by evaluating the contents of the file. And yes, there are people who have already done all the work for you: it is called libmagic (the thing that gives the file command line tool). You can use it with Perl, for example. File :: MMagic .
source share