Solved

magic number in unix

Posted on 2000-02-22
5
1,192 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 50 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

623 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