Extended file attributes on macOS
You can store metadata on any file in the mac filesystem(HFS+). If you want to ensure the file has a specific encoding, or if you want to place a checksum with the file you can use file attributes.
Setting and reading are easy on macOS with the xattr
utility:
> touch something.txt
> xattr -w xyz 123 something.txt
> xattr -p xyz something.txt
123
In this example we wrote(xattr -w
) an attribute onto the file and printed
it(xattr -p
) to see that it was written.
You can list the file attributes with a cryptic option for ls, ls -l@
. Try
doing this on your ~/Downloads
dir to learn something cool about how macOS
treats files coming from the internet.