exa

Extended attributes (xattrs)

exa is able to list a file’s extended attributes, also known as xattrs.

Unlike ‘standard’ metadata items such as a file’s permissions or inode number, extended attributes are user-definable, and can be used for a variety of purposes:

  • macOS Finder will store a file’s tags and labels.
  • Safari will store the date and origin of a downloaded file.
  • cURL can store the origin and MIME type of a download.
  • youtube-dl can store the metadata of a downloaded video or song.

Their presence will be signified by a @ symbol in the permissions column when using the details view.

exa --long --extended 'World map.pdf'
.rw-r--r--@ 459k ben 23 May 19:34 World map.pdf
                                  ├── com.apple.FinderInfo (len 32)
                                  ├── com.apple.metadata:_kMDItemUserTags (len 42)
                                  ├── com.apple.metadata:kMDItemWhereFroms (len 105)
                                  └── com.apple.quarantine (len 57)

Do I need to pass an option to show that a file has attributes?

No — having a version of exa that supports them will automatically look for extended attributes. The --extended option only tells exa to print the keys and sizes out.

How can I actually read the values of extended attributes?

Like ls, exa only lists the attributes’ names, rather than their values, which might be large strings of binary data. However, you probably also have a program to read these values.

If you have the xattr command, you can read an attribute with:

xattr -p [attribute] [file]

If you have the getfsattr command, you can read all attributes with:

getfattr -dm- [file]