?
Solved

magic number in unix

Posted on 2000-02-22
5
Medium Priority
?
1,209 Views
Last Modified: 2008-03-06
What is the magic number in unix???
0
Comment
Question by:bolotin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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

719 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