File "type"

Robert Bedichek robertb at cs.washington.edu
Sun Sep 23 16:50:52 AEST 1990


In article <171 at alchemy.UUCP> bbs at 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
<text deleted>

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 at 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



More information about the Comp.unix.programmer mailing list