Solved

magic number in unix

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now