Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!rpi!pawl.rpi.edu!tale From: tale@pawl.rpi.edu (David C Lawrence) Newsgroups: comp.unix.questions Subject: Re: Detecting type of file in a program Message-ID: Date: 4 Feb 89 15:10:53 GMT References: <192@henry.ece.utexas.edu> <9587@smoke.BRL.MIL> Sender: usenet@rpi.edu Reply-To: tale@pawl.rpi.edu Organization: The Octagon Room Lines: 30 In-reply-to: gwyn@smoke.BRL.MIL's message of 4 Feb 89 07:45:30 GMT Just something to note here, too, since this is c.u.questions and not c.u.wizards (wizards already know this). `file' is a handy utility for a lot of things, but alas, it is quite easy to trip it up. For one thing, it does not know lisp (as indicated on the manual page) and for another, comments can really screw it up. In fact, cpp directives can screw it up too. I have a programme that starts out with lots of #defines. `file' loves to think that it is just ascii text. Another programme has a large comment section at the beginning of the form /*text\n *more text\n */. This, alas, is just but ascii text to `file'. (Aside: I am curious how it determines something is English text rather than just ascii text.) Another thing that can screw-up `file' is short, tabular information, as near as I can tell. I have a README in my bin directory which consists of the name of each programme, the language it is written in and a message about what it does. This is reported by `file' to be *roff, et al, input. Similar behavious has been exhibited on other files. One thing I -love- file for is reading raster headers; it tells me useful information in a nice compact way -- size of image, encoding information (run-time encoded, standard format, etc). For the purposes of the original poster, `file' is a great way to find scripts and machine executables; don't rely on it for source files, especially, though. Dave -- tale@rpitsmts.bitnet, tale%mts@rpitsgw.rpi.edu, tale@pawl.rpi.edu