It says here...


...that the HFS+ file system in OSX supports "multiple named forks". How do I create a named fork at command line, and then how do I store data in it? Also, what are the maximum number of bytes I can place in my named fork?

2 Answers 2


Extended attributes is what you're looking for. xattr will allow you to view and modify extended attributes at the command line. Look at the man page for more details, but in brief you can write one with the following command

xattr -w com.foo.myattribute "A bunch of data" /path/to/file

  • Extended attributes are distinct from named forks. The resource fork is listed as though it's an extended attribute using ls -l@ but xattr does not let you create and manipulate arbitrary named forks. Extended attributes have a maximum size of 128K or 64M depending where you read, whereas named forks an be any size. Named forks are not well documented and the connection between them and extended attributes is poorly understood. Mar 8, 2021 at 2:02

I don't know about named forks except the resource fork. I can create it like so in Terminal (Bash shell):

echo "data fork area" > /tmp/test.txt
echo "resource fork area" > /tmp/test.txt/..namedfork/rsrc
cat /tmp/test.txt
cat /tmp/test.txt/..namedfork/rsrc

I don't know about size limitations.

You can also copy a binary executable into the resource fork, and extract the bytes back out into a file, and execute that file:

cp /usr/bin/whoami > /tmp/test.txt/..namedfork/rsrc
# get ready for some bells to sound in your terminal
cat /tmp/test.txt/..namedfork/rsrc > /tmp/test.bin
chmod u+x /tmp/test.bin

Note that the whoami command is kind of weird when you do this because it's really the id command, and so when you restore it, it reverts to the id command and you can do man id to learn more about that.

  • 1
    This method creates an extended attribute with the name com.apple.ResourceFork. You can view it with the xattr command.
    – iWill
    Feb 22, 2016 at 4:06
  • @iWill: Yes the newer extended attribute feature seems to provide an additional interface to the very old resource fork feature. Jun 9, 2016 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .