magic(5) definition for first 2kb of a file (FreeBSD/MacOS)
supadupa at gmail.com
Thu Nov 17 20:16:28 MST 2011
I'm looking at the magic(5) man page, and I'm still all sorts of lost while
creating the start of a simple magic definition. I'll need to eventually
run this on FreeBSD, and such I'm using my ibook since the man pages appear
identical. It might work the same in Linux, but I'm not testing that yet.
I'm essentially trying to look within the first 1-2kb with the file(1)
command, supply my own additional magic file, and see if the text "quick
brown fox" (as an example) is present.
I'm almost ready to cheat and use this instead:
zcat file.txt | head -c 2048 | tail -c 1024 | grep -o "quick brown fox"
I'm tinkering with file magic first just to see. I've thought of using this
approach no few times in the past but chicken out with a script etc.
More information about the PLUG