Detecting type of file in a program

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Feb 4 17:45:30 AEST 1989


In article <192 at henry.ece.utexas.edu> po at 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.



More information about the Comp.unix.questions mailing list