I am beginning to wonder if this is even possible as multiple searches on SO, Google, Bing and linuxquestions.org have turned up nothing.
I am interested in extending the magic patterns located in /usr/share/magic
(used by the file(1)
utility) to recognize files based on data at or near the end of the file. I have been able to do this for the beginning of a file, as well as for arbitrary offsets into the file from the beginning.
The man page does a pretty good job of illustrating some standard usage cases; unfortunately, it does not seem like there is a way to index from the end as opposed to the beginning. The only workaround I could come up with was to adopt a scripted approach using tac
and/or lreverse
but feel these may be unfriendly to binary data.
Also, I wanted to avoid any other scripted processing - I feel like this should be doable with the right file magic. Any ideas?