in reply to file type
% file /usr/bin/perl /usr/bin/perl: ELF 32-bit LSB executable, Intel 80386, version 1, dyna +mically linked (uses shared libs), stripped
I tried running file on a few of my C source files, and got back 'C program text'. So file can figure out when an ASCII file consists of C code.
Looking at the manpage for file (on RedHat), I see:
Two observations: file guesses on the contents of an ASCII file by examining the first few blocks of the file, and the files you tested this on happen not to contain the strings that file is looking for.If an argument appears to be an ASCII file, file attempts to guess its language. The language tests look for par ticular strings (cf names.h) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a troff(1) input file, just as the keyword struct indicates a C pro gram. These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some miscellany (such as tar(1) archives) and determine whether an unknown file should be labelled as `ascii text' or `data'.
I'm not sure what the best solution is. The file extensions will certainly be useful, as others have suggested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: file type
by Anonymous Monk on Feb 09, 2001 at 05:21 UTC | |
by sierrathedog04 (Hermit) on Feb 09, 2001 at 16:39 UTC |