Alex Rivera | Logout

How to create a custom magic file database

Asked 2011-08-29T21:27:19.240
30

The unix file command uses a "magic" file database to determine which type of data a file contains, independently of the file's name or extension.

I need to craft my custom magic database for testing purposes, but I fail to find how to create one.

Edit
Report

1 Answer

3

I'm using the following magic file now for my unit tests:

0       search/1/c      =<?php                  PHP script text
!:mime  text/x-unittest

With it, every php file (beginning with <?php) will get the MIME type text/x-unittest.


Also see http://cweiske.de/tagebuch/custom-magic-db.htm

answered 2011-08-31T09:49:46.720

Your Answer