1819696 Members
3457 Online
109605 Solutions
New Discussion юеВ

file type

 
bossuyt_2
Occasional Advisor

file type

To get the type of a file on HP-UX 10.20 I use the command :
file xxxxxxx
I have this type I don't know :
awk program text

I can't open with vi or cat ? ?
I don't know awk language ???
I only want to see this file with an EDITOR ? ? is it a object ?

Thank's . . .

6 REPLIES 6
Massimo Bianchi
Honored Contributor

Re: file type

Hi,
you MAY open it with a text editor like vi, better if to try first with the command:

strings "filename" | more

Thus you can see if it is really readable or not.



An awk program text is usually a text program, huma readable, but it maybe a mismatch in the pattern recognition routine. So, before editing it, try to visualize it.

Massimo
Jean-Louis Phelix
Honored Contributor

Re: file type

I heard once one about that ... The guy who wrote 'file' didn't know 'awk'. 'file' uses /etc/magic to determine file types. So when nothing is matching in /etc/magic the guy said : if I don't know it, it must be a awk program ...

So it would simply mean that 'file' didn't recognize the file type.

Regads.
It works for me (┬й Bill McNAMARA ...)
Michael Schulte zur Sur
Honored Contributor

Re: file type

Hi,

is everything you wrote, the output of the file command?

greetings,

Michael
Umapathy S
Honored Contributor

Re: file type

I have seen this many times happening. Most of the times it is either a corrupted binary file or a malalighned ftped file.

Jean is the story true. As far as I know the initial file was written by Ian F Darwin. Did he say like that :-)
Arise Awake and Stop NOT till the goal is Reached!
Bruno Ganino
Honored Contributor

Re: file type

I think that you can use "vi" or "ex" or "ed" for display this file.
Bruno
Torino (Turin) +2H
Bill Hassell
Honored Contributor

Re: file type

Remember that the file command uses magic! Well, /etc/magic to be specific and it is nothing more than a guessing program. There are very few specific file types in Unix, devicefiles (block and character), directories (they are files too), FIFO's, symbolic links, socket files, and of course 'plain, ordinary, regular' files. The problem is that the contents of a regular file is defined by the program that created it and until you look inside, there is no way to tell what the file might be.

So file uses the /etc/magic file to 'guess' what kind of data might be inside. You may have heard the term 'magic number' in Unix...it refers to specific strings or numbers that are always the same for a specific file such as an executable. For example, the file command says about itself:

# file /usr/bin/cut
/usr/bin/file: PA-RISC1.1 shared executable dynamically linked

and grep'ing through the /etc/magic file for PA-RISC1.1, you'll find:

# grep "PA-RISC1.1 shared executable" /etc/magic
0 long 0x02100108 PA-RISC1.1 shared executable


The code says: starting at the first word in the file, if the hex digits are: 02100108 then it is a shared executable for PA-RISC CPUs version 1.1 and higher. To check this out:

# xd /usr/bin/file | head -1
0000000 0210 0108 0512 4000 0000 0000 0000 0000

And sure enough: right after the starting address 0000000 is 0210 0108. Now here's the rub: suppose I create a binary file consisting of a bunch of numbers where the first number is 0x02100108. Then file will say that it is an executable but it would be wrong. Similarly:

# echo '%!PS-Adobe-' > xy
# file xy
xy: postscript file

Clearly xy is not a usable Postscript file but the file command guesses that it is. And as mentioned, awk is just a fall-through result. So before you cat a file, verify the contents with either:

# cat -v /somefile | more
# xd -xc /somefile

Note that vi is fairly friendly in that it recognizes binary exectuables (regardless of whether they have the execute bit set) and will handle binary characters without messing up your screen.


Bill Hassell, sysadmin