Re: How to determine file type



On Wed, 23 May 2001, mr zali wrote:

Hi,

I'm try to developed application like GMC. I have a
problem with file that have no ext. For example README
file. How I want to determine that file are 'text'
file or 'binary' file? 
Any idea?

In Unix there is no sutch thing as a "binary" or "text file".

Try "emacs /kernel" and se whats happening. And Yes
emacs can edit all kind of binary files and you can do things
like "cat /etc/passwd > /dev/dsp" and lissen to your password
file.

Some files have "well known patterns" inside and there is
a program. called file, so that you can do things like

file /kernel
/kernel: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
dynamically linked, not stripped

The patterns "file" work with are in a file called
"magic"  (On FreeBSD it is /usr/share/misc/magic). In this file
the patterns are described.

Göran Hasse

----------------------------------------------------------------
Göran Hasse            email: gh raditex se     Tel: +46 8 694 92 70
Raditex AB             http://www.raditex.se    Fax: +46 8 442 05 91
Sickla Alle 7, 1tr                              Mob: 070-5530148
131 34  NACKA, SWEDEN






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]