我必须创建一个魔术文件,它可以在第42个字节上检测到42的结果。我创建了以下行,然后编译
40 search 42 this is a 42 file
但是当我用这个内容运行file -m <file_name>
时
00000000 00000000 00000000 00000000 00042
我收到信息
Warning: type `00000000 00000000 00000000 00042' invalid
file: could not find any valid magic files! (No such file or directory)
你的魔法应该是这样的:
0 search/42 42 File containing "42"
!:mime text/x-42
这是我的测试:
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
x@ubuntu:~$