Unix binary/text files: is there a difference?

Mark Warren mwarren at rws1.ma30.bull.com
Thu Mar 21 06:50:11 AEST 1991


jdubb at bucsf.bu.edu (jay dubb) writes:


>    I've looked in a bunch of C and Unix books, and can't seem to find
>a good explanation of this - maybe someone can help... Is there a way
>to tell (from a C program) whether a given file contains text or data?

There is no difference in Unix.  Other operating systems have some flags
associated with files that indicate contents, format, etc., but Unix
treats all files as uninterpreted byte streams.

Unix supplies a "file" utility that tries (usually successfully) to guess
what the file is, but it is nothing more than a guess that applies some
heuristics to the first few bytes read from the file.

Sorry, there's no guaranteed way to do it.
--

 == Mark Warren                      Bull HN Information Systems Inc. ==
 == (508) 294-3171 (FAX 294-3020)    300 Concord Road     MS852A      ==
 == Mark.Warren at bull.com             Billerica, MA 01821              ==



More information about the Comp.unix.programmer mailing list