There is a file command, which, in turn, uses the magic library, the magic library reads from the file found in / etc, magic (it depends on the installation and may vary), which describes in detail the first few bytes of the file and tells file which file it is: jpg, binary, text, shell script. Sourceforge has an old version of libmagic. By the way, there is a corresponding answer to this one here .
Hope this helps, Regards, Tom.
t0mm13b
source share