Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

magic number in unix

Posted on 2000-02-22
5
Medium Priority
?
1,225 Views
Last Modified: 2008-03-06
What is the magic number in unix???
0
Comment
Question by:bolotin
  • 4
5 Comments
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2547078
It is a known sequence of bytes that always show up in a file of a certain type.  You can usually assume that if the sequence shows up in the right spot in the file, you have a file of the given type.  For example, if the file starts with 0x000001b3 it is an MPEG video stream.  The information is usually kept in a magic file.  The "file" command uses it to identify files.

Rob
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2547100
BTW:  you can look at the contents of the magic file to find the magic numbers of well-known file types.  Since the location of the magic file depends on the flavor of *nix you are using, try

find / -name 'magic'

Then pipe the file through the more command to look at it.

Rob
0
 

Accepted Solution

by:
cartoon022100 earned 150 total points
ID: 2550049
the file "/etc/magic" contains all magic numbers. the "file" command uses this magic number to compare with the contents in the file.depending upon the matching ,the file command gives output as ascii text  ot C file or binary file etc etc

"man magic" may help u more
Inigo
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2554760
The magic file is not located at /etc/magic on all systems.
0
 
LVL 3

Expert Comment

by:RobWMartin
ID: 2616313
bolotin,

Hate to be pushy, but you need to decide who gave you the right answer first.  You can accept one of my comments as the answer, unless you feel cartoon gave you more useful info.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question