Skip to main content

libmagic

file -b --mime-type README.md # text/plain
file -bsi /dev/nul # application/x-empty; charset=binary
flagdemo
-i,--mimetext/plain; charset=utf-8
--mime-typetext/plain
--mime-encodingutf-8
-z,--uncompress
-Z,--uncompress-noreport
  • -P, --parameter
    • bytes=1048576 - 最多读取 1MB
    • encoding=65536 - 扫描多少 bytes
    • elf_notes=256
    • elf_phnum=2048
    • elf_shnum=32768
    • indir=50 - indirect
    • name=50
    • regex=8192

magic

  • magic.4
  • magic/Magdir
    • file 现有的 magic 定义
  • /usr/local/share/misc/magic - 未编译
  • /usr/local/share/misc/magic.mgc - 编译后