Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!bu.edu!bucsf.bu.edu!jdubb From: jdubb@bucsf.bu.edu (jay dubb) Newsgroups: comp.unix.programmer Subject: Unix binary/text files: is there a difference? Message-ID: <77384@bu.edu.bu.edu> Date: 20 Mar 91 17:24:03 GMT Sender: news@bu.edu.bu.edu Distribution: usa Organization: Computer Science Department, Boston University, Boston, MA, USA Lines: 20 Originator: jdubb@bucsf.bu.edu 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? The reason I'd like to know, is that I've noticed that if you have a file into which you have done something like write(fid,&an_int,sizeof(int)) and then you take this file to another machine via FTP (in binary mode), and try to read() the int back, it doesn't work (because of byte-order differences, I assume). So, what I'd like to know is, is there a difference (in terms of something stat() could tell me, for example) between straight text files and files which contain raw numbers (without searching through the whole file to check, hopefully)? the 'file' command seems to be able to do this - I've tried it on a text file, and on a file with raw ints and floats, and it says "text" and "data" respectively. Does it really know, or is it making a guess (and if so, how good is its method of guessing?)? Hoping for an explanation of Unix binary/text files... P.S. If this is the wrong group for this type of question, or you know of a good book that describes this in detail, please let me know.