Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: Detecting type of file in a program Message-ID: <9587@smoke.BRL.MIL> Date: 4 Feb 89 07:45:30 GMT References: <192@henry.ece.utexas.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 9 In article <192@henry.ece.utexas.edu> po@volta.ece.utexas.edu () writes: >How can I tell whether a file is text or an object file ? >Is there a better way than using : > system("file filename > /tmp/tempfile") Anything you do will be pretty much what "file" does, namely, inspect yay many bytes of the file to see if there is a known "magic number" header present or if there are non-diplayable byte values present.