File command + total retrun list

0

With file command we can get the file type. File returns a unique answer for each file type. I want to get the total list that file can return for linux & solaris.

For example, I have a partial list of file's return output. Unfortunately I can't see the total list from manual page.

 ASCII C program text  
 ASCII C++ program text  
 ASCII C program text, with CRLF
 ASCII C program text, with very
 ASCII English text   
 ASCII English text, with CRLF line
 ASCII English text, with escape sequences
 ASCII English text, with very long
 ASCII HTML document text  
 ASCII HTML document text, with very
 ASCII Java program text  
 ASCII Java program text, with CRLF,
 ASCII Java program text, with very
 ASCII make commands text  
 ASCII make commands text, with very
 ASCII text    
 ASCII text, with CRLF line terminators
 ASCII text, with escape sequences 
 a /usr/bin/perl script text executable 
 Bourne-Again shell script text executable 
 Bourne shell script text executable 
 core file (Xenix)   
 C++ program text   
 data     
 exported SGML document text  
 extended 669 module data  
 HTML document text   
 ISO-8859 English text   
 Non-ISO extended-ASCII English text  
 Non-ISO extended-ASCII English text, with CRLF
 Non-ISO extended-ASCII English text, with very
 PC bitmap data   
 PC color icon data  
 PC color pointer image data 
 PC icon data   
 PDF document, version 1.2  
 TOC sound file   
 UTF-8 Unicode text, with CRLF line
 XML document text

jennifer

Posted 2010-10-30T21:01:07.033

Reputation: 897

Please don't tell me you're trying to parse the output of file like this... – Daenyth – 2010-10-30T21:08:57.633

@Daenyth I need the total list that file can return and according to the list I want to verify file type – jennifer – 2010-10-30T21:12:55.743

1You need to approach this differently. Whatever it is that you're trying to accomplish, this is the wrong way to go about it. Please be specific about what you're really trying to do. – Paused until further notice. – 2010-10-30T23:01:37.263

Dennis I return about my question – I need all return answers of file command How can I get this list , what wrong with this question – jennifer – 2010-10-31T04:56:28.367

The problem is that the possible output of the file command is buried deep inside the source code, because it contains several modules that are specifically written for, let's say, tarballs. Think about the possible combinations of "with CRLF line terminators". There is probably a huge number of possible types. – slhck – 2010-10-31T09:09:18.393

@slhck hi the goal is to find common denominator for the ASCII files , mybe its allot of work but I think its possible – jennifer – 2010-10-31T16:50:09.673

Answers

1

You can't get an exhaustive list of output from the file command. The output it generates is determined by the “magic” database, which changes with every upgrade of the program and can be customized by the system administrator and the user. Furthermore, strings returned by file can be built from several pieces, for example text files sometimes get an indication of character encodings, image files can have their size shown, etc.

Under Linux, file -i shows the MIME type (e.g. text/plain, image/jpeg) rather than a string destined for humans. If you were thinking of parsing the output from file, you want file -i. There is an official list of MIME types, but it is not exhaustive: there are plenty of non-standard types out there. Furthermore file -i may complement the MIME type with encoding information (e.g. text/plain charset=utf-8).

Gilles 'SO- stop being evil'

Posted 2010-10-30T21:01:07.033

Reputation: 58 319