This works best for telling the different forms of text, like ASCII and UTF-8, apart. If attributes and magic can’t tell what the file is, file has one more trick up its sleeve: it peeks. You can browse those text files if you’re interested: they contain many fascinating tidbits of information, and can be helpful to developers at any level. It matches those against the patterns it holds in /usr/share/file/magic.mgc, which it compiles in turn from the definitions kept in files inside /usr/share/file/magic. If that doesn’t identify the file properly, it then turns to magic, or, to be more precise, the file’s magic number. The first is to ask macOS for the file attributes, which is what the Finder does too. Its man page, one of the best you’ll ever find, explains that file uses three unrelated systems to establish what the file is. So how does file do so much better than the Finder? But most of the time, the plain command and file path will be all that you’ll want to use. Test.tex: LaTeX 2e document text, ASCII textįile has plenty of options if you want to do more sophisticated things with it, like retrieve the classic file type and creator code, return MIME type strings rather than normal results, or look inside compressed files. Point file at it, though, and you’ll be informed A LaTeX document named test.tex, for example, will just be shown as a text file. The Finder isn’t always good at grokking different types of text file. So, if nothing else, file is a useful way to check Mach-O code files to see if they’re still 32-bit. Applications/iMovie.app/Contents/MacOS/iMovie: Mach-O 64-bit executable x86_64 To find out more, you’ll have to point file at the app code itself:įile /Applications/iMovie.app/Contents/MacOS/iMovie Rather than telling you that it’s an app bundle. It’s a bit less helpful with app bundles, though: Meaning that is a command tool which is 32-bit only. sbin/autodiskmount: Mach-O executable i386 Just give it a file to inspect, and it’ll tell you what it knows about it. This article looks at the definitive way to discover exactly what every file and Finder item is, and the fascinating ‘magic’ system which makes that possible: using the command tool file.įile is very simple to use. QuickLook doesn’t want to know them, and the Finder’s Get Info dialog isn’t much more helpful. text and QuickLook previews its contents as text, you can be confident that’s what it is.īut every so often, you’ll come across one or more files which are more obscure. Most files and packages – folders cunningly disguised as files – have extensions and other telltales which reveal what they are.
0 Comments
Leave a Reply. |