Path: utzoo!attcan!uunet!wuarchive!mit-eddie!uw-beaver!uw-june!robertb From: robertb@cs.washington.edu (Robert Bedichek) Newsgroups: comp.unix.programmer Subject: Re: File "type" Message-ID: <13114@june.cs.washington.edu> Date: 23 Sep 90 06:50:52 GMT References: <171@alchemy.UUCP> Reply-To: robertb@june.cs.washington.edu (Robert Bedichek) Organization: University of Washington, Computer Science, Seattle Lines: 43 In article <171@alchemy.UUCP> bbs@alchemy.UUCP (BBS Administration) writes: > > Could someone explain how the command "file" works? Specifically, I am >writing a program that allows users to navigate their $HOME directory and I suggest that you read the man page for 'file'. Also, read the file that the man pages specifies as the database that 'file' uses. You can find lots of useful stuff by reading man pages and examining user-readable system files. It is something that still distinguishes most versions of UNIX from most other operating systems. >Anyhow, once they select a file for reading, I'd like to be able to >determine if the file is "ascii text" as the program "file" reports >when this is true, and if not, inform the user that the contents are >NOT ascii text and that they may want to reconsider. > > Should I make a pass through the contents and make sure that each >character has the high bit OFF (so it's 7-bit data) or what? I don't >need to determine what kind of file it is, just whether or not it's >something the editors will "like." There are many file types that editors will like besides files reported by 'file' as text. For example shell scripts are usually reported as such and not as text. So the result of 'file' isn't what I think that you want. Also, some text editors can edit any file, including executable files. > >Thanks in advance! Sure, I hope that this helps. Rob Bedichek robertb@cs.washington.edu > >-- John > >John Donahue, Senior Partner | UUCP: ucrmath!alchemy!{bbs, gumby} | The Future > Alchemy Software Designs | INET: {bbs, gumby}@alchemy.UUCP | Begins Now >-------------------+---------+-------------------------------------+----------- >Communique On-line | +1-714-243-7150 {3, 12, 24, 96HST} Bps. 8-N-1 | Next Wave: >Information System | Alchemy Software Designs Support System | Communique