The “file” command: annotations

This post is part of a series. For an introduction to the file command, and the other posts in the series, see the first post. When writing a "magic pattern" file for the file command, you can include some special lines that start with "!:". The documentation doesn't name this feature, but I'll call it … Continue reading The “file” command: annotations

The “file” command: binary and text files

This post attempts to explain a few things about how the file command deals with binary vs. text files, primarily from the standpoint of someone writing "magic patterns" for it. For an introduction to the file command, and my other posts on the topic, see the first post. Note that by "ruleset", I mean a … Continue reading The “file” command: binary and text files

The file command and black magic (Part 2)

This is a continuation of Part 1. I'm discussing random trivia about the file command. For a list of other posts about the file command, see this post. Format specifiers Consider the format specifiers that can appear in the "message" field: %s, %d, %u, etc. In a previous post, I indicated that I didn't know … Continue reading The file command and black magic (Part 2)

The file command and black magic (Part 1)

For an introduction to the file command, and my other posts on the topic, see the first post. I've come across some undocumented things, and various weirdness, in the behavior of the file command. In this post, I'll go over a few of them. The intended audience is someone writing "magic pattern" rules for file. … Continue reading The file command and black magic (Part 1)

A script to analyze magic patterns for the “file” command

See my previous post for an introduction to the file command, and the "magic patterns" used to configure it. My previous post also introduces some of the terminology used in this post. I've been working on a little Python script named Mgchkj (all the good names were taken) that helps to identify patterns that might … Continue reading A script to analyze magic patterns for the “file” command

Notes on writing “magic” patterns for the “file” command

The file command is a classic Unix-centric utility that guesses the format of a file, based only on the file's contents. It may also print some additional information about the contents of the file. The modern open-source version of it can be found at <https://darwinsys.com/file/&gt;. Other posts about the file command: A script to analyze … Continue reading Notes on writing “magic” patterns for the “file” command