Mac Developer Library Developer


This manual page is for Mac OS X version 10.9

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • To learn how the manual is organized or to learn about command syntax, read the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Developer Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.

XATTR(1)                  BSD General Commands Manual                 XATTR(1)

     xattr -- display and manipulate extended attributes

     xattr [-lrsvx] file ...
     xattr -p [-lrsvx] attr_name file ...
     xattr -w [-rsx] attr_name attr_value file ...
     xattr -d [-rsv] attr_name file ...
     xattr -c [-rsv] file ...
     xattr -h | --help

     The xattr command can be used to display, modify or remove the extended attributes of one or more
     files, including directories and symbolic links.  Extended attributes are arbitrary metadata stored
     with a file, but separate from the filesystem attributes (such as modification time or file size).  The
     metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data.

     One or more files may be specified on the command line.  For the first two forms of the command, when
     there are more than one file, the file name is displayed along with the actual results.  When only one
     file is specified, the display of the file name is usually suppressed (unless the -v option described
     below, is also specified).

     In the first form of the command (without any other mode option specified), the names of all extended
     attributes are listed.  Attribute names can also be displayed using ``ls -l@''.

     In the second form, using the -p option (``print''), the value associated with the given attribute name
     is displayed.  Attribute values are usually displayed as strings.  However, if nils are detected in the
     data, the value is displayed in a hexadecimal representation.

     The third form, with the -w option (``write''), causes the given attribute name to be assigned the
     given value.

     The fourth form, with the -d option (``delete''), causes the given attribute name (and associated
     value), to be removed.

     In the fifth form, with the -c option (``clear''), causes all attributes (including their associated
     values), to be removed.

     Finally, the last form, with either the -h or --help option, displays a short help message and exits

     -l  By default, the first two command forms either displays just the attribute names or values, respec-tively. respectively.
         tively.  The -l option causes both the attribute names and corresponding values to be displayed.
         For hexadecimal display of values, the output is preceeded with the hexadecimal offset values and
         followed by ASCII display, enclosed by ``|''.

     -r  If a file argument is a directory, act as if the entire contents of the directory recursively were
         also specified (so that every file in the directory tree is acted upon).

     -s  If a file argument is a symbolic link, act on the symbolic link itself, rather than the file that
         the symbolic link points at.

     -v  Force the the file name to be displayed, even for a single file.

     -x  Force the attribute value to be displayed in the hexadecimal representation.

         The -w option normally assumes the input attribute value is a string.  Specifying the -x option
         causes xattr to expect the input in hexadecimal (whitespace is ignored).  The xxd(1) command can be
         used to create hexadecimal representations from exising binary data, to pass to xattr.

     The xattr command exits with zero status on success.  On error, non-zero is returned, and an error mes-sage message
     sage is printed to the standard error.  For system call errors, both the error code and error string
     are printed (see getxattr(2), listxattr(2), removexattr(2) and setxattr(2) for a complete list of pos-sible possible
     sible error codes).

     Some attribute data may have a fixed length that is enforced by the system.  For example,

           % xattr -w 0 foo
           xattr: [Errno 34] Result too large: 'foo'

     The attribute must be 32 bytes in length.

     This example copies the attribute from the /usr directory to the MyDir directory:

           % xattr -px /usr
           00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
           00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
           % xattr -l MyDir
           % xattr -wx \
             "`xattr -px /usr`" MyDir
           % xattr -l MyDir
           00000000  00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  |........@.......|
           00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

     ls(1), xxd(1), getxattr(2), listxattr(2), removexattr(2), setxattr(2)

BSD                              Nov 29, 2010                              BSD

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation with the feedback links below.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.