Skip to content

My file doesn’t return the magic file message

I have to create a magic file that can detect a result of 42 on the 42nd byte. I’ve created the following line to then compile

40 search 42 this is a 42 file

but when I run file -m <file_name> with this content

00000000 00000000 00000000 00000000 00042

I get the message

Warning: type `00000000 00000000 00000000 00042' invalid
file: could not find any valid magic files! (No such file or directory)



Your magic should be like this:

0 search/42 42 File containing "42"
!:mime text/x-42

Here’s my test:

x@ubuntu:~$ cat testfile.txt 
00000000 00000000 00000000 00000000 00042
x@ubuntu:~$ file -m magicfile.mgc testfile.txt 
testfile.txt: File containing "42", ASCII text
User contributions licensed under: CC BY-SA
5 People found this is helpful